angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Ng build fails. CssSyntaxError since 1.7.0-rc.0

Open elion opened this issue 8 years ago • 55 comments

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

elion avatar Feb 16 '18 01:02 elion

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.

FrancescoBorzi avatar Feb 16 '18 10:02 FrancescoBorzi

Same here with v1.7.0.

emxjay avatar Feb 16 '18 15:02 emxjay

1.7 is broken. Reverting to 1.6.

wonkim00 avatar Feb 16 '18 19:02 wonkim00

@wonkim00 did that work for you?

nidhididi avatar Feb 16 '18 19:02 nidhididi

Same, 1.7.0 caused failing builds, pinned version to 1.6.0, builds are passing again.

hcornelison avatar Feb 16 '18 20:02 hcornelison

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 avatar Feb 16 '18 20:02 clydin

@clydin I am unable to.

hcornelison avatar Feb 16 '18 20:02 hcornelison

@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 avatar Feb 16 '18 21:02 wonkim00

@wonkim00 thank you, I also had success with cli 1.6.8

nidhididi avatar Feb 16 '18 21:02 nidhididi

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

alfaproject avatar Feb 16 '18 21:02 alfaproject

I am getting the same error with single svg background url.

zygimantas avatar Feb 17 '18 11:02 zygimantas

This is happening with SVG only.

smoke avatar Feb 21 '18 10:02 smoke

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

scandinave avatar Feb 22 '18 08:02 scandinave

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 | }

ConClavi avatar Feb 22 '18 09:02 ConClavi

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

krilllind avatar Feb 22 '18 09:02 krilllind

1.7.1 is solving the issue for me, thanks a lot @clydin

FrancescoBorzi avatar Feb 22 '18 10:02 FrancescoBorzi

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.

charlesc32 avatar Feb 22 '18 23:02 charlesc32

@smoke Would you please reopen this issue, as mentioned above, unquoted urls in css and sass are not working.

krilllind avatar Feb 23 '18 14:02 krilllind

Same error , please reopen this issue

MrJmpl3 avatar Feb 25 '18 09:02 MrJmpl3

Same issue with 1.7.1

FriendOfTheNight avatar Feb 26 '18 14:02 FriendOfTheNight