ng-rspack-build icon indicating copy to clipboard operation
ng-rspack-build copied to clipboard

Angular CLI workspace with several projects

Open manfredsteyer opened this issue 11 months ago • 3 comments

I have an Angular CLI workspace with several projects. When compiling one of them using

npx rsbuild build -c projects/mfe1/rsbuild.config.ts

I get this error message:

error   Failed to build.
error   [rsbuild:html] Failed to resolve HTML template, please check if the file exists: /Users/manfredsteyer/projects/public/ng-rspack/src/index.html

Here is the entire stack trace:

    at getTemplate (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:3436:54)
    at async file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:3478:95
    at async Promise.all (index 0)
    at async Object.handler (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:3459:227)
    at async Object.callInEnvironment (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:2388:30)
    at async modifyBundlerChain (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:4955:124)
    at async generateRspackConfig (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:5116:248)
    at async Promise.all (index 0)
    at async initConfigs (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:5250:25)
    at async createCompiler_createCompiler (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:6352:52)
    at async build_build (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:6405:22)
    at async Object.build (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:6976:29)
    at async Command.<anonymous> (file:///Users/manfredsteyer/projects/public/ng-rspack/node_modules/@rsbuild/core/dist/index.js:7081:41)

manfredsteyer avatar Jan 03 '25 22:01 manfredsteyer

The createConfig util supports a root option that sets the rsbuild's root for execution, have you set it?

createConfig({
  root: __dirname,
  index: './src/index.html'
})

If you have and this is still occurring there may need to be a way to normalize the path regardless of where npx rsbuild is called from, which is the real root cause here.

Coly010 avatar Jan 06 '25 11:01 Coly010

Thanks. I'll try it out and let you know here.

manfredsteyer avatar Jan 06 '25 18:01 manfredsteyer

Hi, I'm also having a project in a sub directory. I use the root option, but I'm not sure what exactly this option should do. As @Coly010 stated, it should be the root for rsbuild. But for me, rsbuild always looks for the tsconfig.app.json in the cwd and not in the root directory. Is this the expected behaviour? Thus, I always have to set the tsconfigPath option or cd into the project directory.

eilensm avatar Jan 07 '25 07:01 eilensm