英文:
angular browser-esbuild error: Could not resolve absolute path [plugin angular-css-resource]
问题
During migrating from angular v15 to v16 in a nx
environment, my build process encounters with lots of errors regarding to my form of addressing assets in scss
files.
For example:
✘ [ERROR] Could not resolve "~apps/platform/src/assets/img/bank-card-overlay.png" [plugin angular-css-resource]
apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.scss:40:24:
40 │ ...image: url("~apps/platform/src/assets/img/bank-card-overlay.png");
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can remove the tilde and use a relative path to reference it, which should remove this error.
The plugin "angular-compiler" was triggered by this import
apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.ts:3:33:
3 │ ...CE__1 from "angular:jit:style:file;./add-credit-card-modal.compo...
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I didn't try using relative path because I need to do it the way it is regarding to maintain development experience.
Any solutions?
英文:
During migrating from angular v15 to v16 in a nx
environment, my build process encounters with lots of errors regarding to my form of addressing assets in scss
files.
For example:
✘ [ERROR] Could not resolve "~apps/platform/src/assets/img/bank-card-overlay.png" [plugin angular-css-resource]
apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.scss:40:24:
40 │ ...image: url("~apps/platform/src/assets/img/bank-card-overlay.png");
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can remove the tilde and use a relative path to reference it, which should remove this error.
The plugin "angular-compiler" was triggered by this import
apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.ts:3:33:
3 │ ...CE__1 from "angular:jit:style:file;./add-credit-card-modal.compo...
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I didn't try using relative path because I need to do it the way it is regarding to maintain development experience.
Any solutions?
答案1
得分: 3
以下是要翻译的内容:
解决我的问题的方法是将以下内容添加到 angular.json 文件中:
"stylePreprocessorOptions": {
"includePaths": [""]
},
英文:
What solved my issue is adding the following to angular.json:
"stylePreprocessorOptions": {
"includePaths": [""]
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论