Ng build fails. CssSyntaxError since 1.7.0-rc.0
Versions
Error occurs since v1.7.0-rc.0
Angular CLI: 1.7.0-rc.0
Node: 8.9.4
OS: win32 x64
Angular: 5.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.0-rc.0
@angular-devkit/build-optimizer: 0.3.1
@angular-devkit/core: 0.3.1
@angular-devkit/schematics: 0.3.1
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.0-rc.0
@schematics/angular: 0.3.1
@schematics/package-update: 0.3.1
typescript: 2.6.2
webpack: 3.10.0
Observed behavior
ERROR in ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./src/assets/styles/page.css
(Emitted value instead of an instance of Error) CssSyntaxError: C:\Users\{omitted}\angular-project\src\assets\styles\page.css:259:2159: Can't resolve '%23linearGradient-1' in 'C:\Users\{omitted}\angular-project\src\assets\styles'
> 259 | background: transparent url("../img/icon.svg") no-repeat 50% 0; ^
260 | }
I get similar error messages for each svg file. The page.css is listed in angular-cli.json styles array.
Repro steps
ng build
Possible breaking commits: https://github.com/angular/angular-cli/commit/4a745c9 https://github.com/angular/angular-cli/commit/fa175d8
I can confirm this bug. I have exactly the same issue.
For me it appeared as soon as I updated to version 1.7, the issue was not in 1.6.
Same here with v1.7.0.
1.7 is broken. Reverting to 1.6.
@wonkim00 did that work for you?
Same, 1.7.0 caused failing builds, pinned version to 1.6.0, builds are passing again.
This appears to be caused by an issue with the processing of the content of certain url encoded inlined svgs. Can someone experiencing this issue provide a minimal reproduction or an svg sample file that exhibits the problem?
@clydin I am unable to.
@nidhididi Yes. After deleting the node_modules folder, editing to "@angular/cli": "~1.6.0" in package.json, and running npm install again (which pulled cli 1.6.8), ng build ran successfully.
@wonkim00 thank you, I also had success with cli 1.6.8
I'm having the same issue and it's something to do with the postcss-cli-resources plugin. Apparently, it doesn't quite support background properties with multiple backgrounds, if the last one is not a URL.
Example:
b {
background:
url('./assets/icons/columns.svg'),
linear-gradient(to top, #0f322c 84%, #071a16 99%);
}
Will get compiled to:
b {
background: url('columns.<hash>.svg');
}
@clydin this is the commit that caused my regression (and possibly the others in this thread): https://github.com/angular/angular-cli/commit/eb102275bdd1a05369ff2d1c588ee4040ef0c45d
I am getting the same error with single svg background url.
This is happening with SVG only.
Happen with src: local('Material Icons'), local('MaterialIcons-Regular'), url(../../assets/fonts/material-icon.woff2) format('woff2'); too with v 1.7.1
Ok. Just wrap url content inside "", fix the problem
ERROR in ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./src/styles.scss (Emitted value instead of an instance of Error) CssSyntaxError: /Users/json/OneDrive/MyProjects/ArtNgCore/node_modules/material-design-icons/iconfont/material-icons.css:10:12: Can't resolve '../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf)%20format(%27truetype%27' in '/Users/json/OneDrive/MyProjects/ArtNgCore/src'
8 | url(MaterialIcons-Regular.woff2) format('woff2'), 9 | url(MaterialIcons-Regular.woff) format('woff'),
10 | url(MaterialIcons-Regular.ttf) format('truetype'); | ^ 11 | } 12 |
ERROR in ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./src/styles.scss (Emitted value instead of an instance of Error) CssSyntaxError: /Users/json/OneDrive/MyProjects/ArtNgCore/node_modules/material-design-icons/iconfont/material-icons.css:8:12: Can't resolve '../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2)%20format(%27woff2%27' in '/Users/json/OneDrive/MyProjects/ArtNgCore/src'
6 | src: local('Material Icons'), 7 | local('MaterialIcons-Regular'),
8 | url(MaterialIcons-Regular.woff2) format('woff2'), | ^ 9 | url(MaterialIcons-Regular.woff) format('woff'), 10 | url(MaterialIcons-Regular.ttf) format('truetype');
ERROR in ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./src/styles.scss (Emitted value instead of an instance of Error) CssSyntaxError: /Users/json/OneDrive/MyProjects/ArtNgCore/node_modules/material-design-icons/iconfont/material-icons.css:9:12: Can't resolve '../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff)%20format(%27woff%27' in '/Users/json/OneDrive/MyProjects/ArtNgCore/src'
7 | local('MaterialIcons-Regular'), 8 | url(MaterialIcons-Regular.woff2) format('woff2'),
9 | url(MaterialIcons-Regular.woff) format('woff'), | ^ 10 | url(MaterialIcons-Regular.ttf) format('truetype'); 11 | }
Same issue as @embryologist Referring to files via css url() without "" causes the build to crash. This should work, as it has a different meaning when using for example sass.
Can confirm that it's not working in 1.7.1
1.7.1 is solving the issue for me, thanks a lot @clydin
1.7.1 did not fix the issue for me. I had to roll back to 1.6.0. I'm seeing the error on unquoted urls for fonts.
@smoke Would you please reopen this issue, as mentioned above, unquoted urls in css and sass are not working.
Same error , please reopen this issue
Same issue with 1.7.1