We have an Angular library project which is using another library for images. Some of our scss are using images as background-image from this library. It used to work prior to 14 version without any issue. We are upgrading library from Angular 10 to 14.Till 13 version it compiles successfully without error and creating dist folder but on upgrading to 14 version , first it gives some warning about unable to read image file and these will be ignored and then failed on copy assets stage with error..
warning:
WARNING: postcss-url: C:my-libgridgrid.scss:486:3: Can't read file 'C:my-libgridimgsprites.png', ignoring
Error:
× Copying assets
Cannot read assets from a location outside of the project root.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build-common: `ng build --project=ng-solution-common-ui-library --configuration production`
Our scss file have specified background-image like below:
css-class{
background-image: url('img/sprites.png');
}
Please Note that I cannot specify assets folder in angular.json on a library project. Also this another library having images is a npm dependency and is under node_modules..
Part of Angular.json configuration
"projectType": "library",
"root": "projects/my-library",
"sourceRoot": "projects/my-library/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "projects/my-library/tsconfig.lib.json",
"project": "projects/my-library/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/my-library/tsconfig.lib.prod.json"
}
}
I am stuck on this for a long time. Any help would be really appreciated.
Thanks
Nishtha
I have tried to give complete path to library in scss file like
css-class{ background-image: url('second-lib/img/sprites.png'); }
Please note this second-lib is also with us , designed only to keep css and images at common place.
I have tried to add assets, stylePreprocessorOptions in angular.json, but both are not allowed under it.
Underlined NodeJS is 14.
user26436857 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.