angular browser-esbuild error: Could not resolve absolute path [plugin angular-css-resource]

huangapple go评论199阅读模式
英文:

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:

  1. [ERROR] Could not resolve "~apps/platform/src/assets/img/bank-card-overlay.png" [plugin angular-css-resource]
  2. apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.scss:40:24:
  3. 40 ...image: url("~apps/platform/src/assets/img/bank-card-overlay.png");
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. You can remove the tilde and use a relative path to reference it, which should remove this error.
  6. The plugin "angular-compiler" was triggered by this import
  7. apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.ts:3:33:
  8. 3 ...CE__1 from "angular:jit:style:file;./add-credit-card-modal.compo...
  9. ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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:

  1. [ERROR] Could not resolve "~apps/platform/src/assets/img/bank-card-overlay.png" [plugin angular-css-resource]
  2. apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.scss:40:24:
  3. 40 ...image: url("~apps/platform/src/assets/img/bank-card-overlay.png");
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. You can remove the tilde and use a relative path to reference it, which should remove this error.
  6. The plugin "angular-compiler" was triggered by this import
  7. apps/platform/src/app/shared/components/add-credit-card-modal/add-credit-card-modal.component.ts:3:33:
  8. 3 ...CE__1 from "angular:jit:style:file;./add-credit-card-modal.compo...
  9. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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 文件中:

  1. "stylePreprocessorOptions": {
  2. "includePaths": [""]
  3. },
英文:

What solved my issue is adding the following to angular.json:

  1. "stylePreprocessorOptions": {
  2. "includePaths": [""]
  3. },

huangapple
  • 本文由 发表于 2023年5月13日 23:05:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243406.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定