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 have similar issue with angular/cli 1.7.4 -

(Emitted value instead of an instance of Error) CssSyntaxError: /Users/xxx/xxx/website/web-src/app/pages/home-page/home-page.component.scss:104:30: Can't resolve ../../../../node_modules/assets/images/background.svg' in '/Users/xxx/xxx/website/web-src/app/pages/home-page
  102 |         }
  103 |         &.bg-1 {
> 104 |             background-image: url("~/assets/images/background.svg");
      |                              ^
  105 |         }
  106 |     }```

Can you point me to some fix? Version 1.6.3 works good, but i need some fix from 1.7 :(

jakubjosef avatar Apr 20 '18 12:04 jakubjosef

@jakubjosef Check what version of node-sass you are running, I bumped my version up from 4.8.1 to 4.8.3 and it solved my issue.

krilllind avatar Apr 20 '18 13:04 krilllind

@jakubjosef if the file is a copied asset then the tilde should not be used. Otherwise the output will contain two copies of the file. If this is not the case then the path should be relative to the containing stylesheet's location.

The tilde should in general be avoided as it happens to work currently due to the underlying presence and configuration of webpack but is not guaranteed to work moving forward.

clydin avatar Apr 20 '18 14:04 clydin

Do you guys have only the problem with svg? I have the same error as others using svg, png. Is there any workaround to this bug? I need 1.7.4 so I don't wont to go back to 1.6. @RandomUser0912421 - your's solution isn't working too - the same error

MaciejWWojcik avatar Apr 21 '18 08:04 MaciejWWojcik

@clydin Thanks for proposal, but it's not work. I still have node_modules in path :(

jakubjosef avatar Apr 24 '18 12:04 jakubjosef

Guys, Did you try to specify path in this way? For me it's working fine.

$icon: url("/../../../../../assets/local_florist.png");
.icon {
  background: $icon;
}

"@angular/cli": "^1.7.3"

MaciejWWojcik avatar Apr 25 '18 07:04 MaciejWWojcik

has this been solved?

BobbyT avatar Apr 27 '18 15:04 BobbyT

They tried npm rebuild node-sass --force?

pacozevallos avatar May 05 '18 14:05 pacozevallos

@MaciejWWojcik yes, this is exactly the workaround i used. @pacozevallos yes, didn't help.

jakubjosef avatar May 07 '18 15:05 jakubjosef

Same issue with angular/cli 1.7.1

suraj021 avatar May 10 '18 09:05 suraj021

Stoped seeing weird behaviors after upgrading to Angular 6.0

ConClavi avatar May 10 '18 10:05 ConClavi

Warning: the path it´s not relative to the partial .scss file

For many people the error will be caused when trying to load a resource relative to the file. What Webpack is doing is trying to resolve the paths relative to the entry file.

You can put the SVGs or webfonts inside the assets folder and update the path accordingly.

baamenabar avatar May 15 '18 15:05 baamenabar

NG Sass build fails still for the same reason. Configuration:

{ npm: '6.4.1', ares: '1.10.1-DEV', cldr: '32.0', http_parser: '2.7.0', icu: '60.1', modules: '57', nghttp2: '1.25.0', node: '8.10.0', openssl: '1.0.2n', tz: '2017c', unicode: '10.0', uv: '1.19.1', v8: '6.2.414.50', zlib: '1.2.11' }

Angular 6 stable and latest angular client. MacOSX on iMac and Macbook Pro. The scenario is a I want to include bulma-extensions. When in my style.sass I do @import '~bulma' @import '~bulma-extensions'

result is: ERROR in ./src/styles.sass (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/styles.sass) Module build failed: Not enough space

cirix avatar Oct 06 '18 11:10 cirix

Anyone found a fix for this? does going back to 1.6-rc.0 fixes the error?

iChristosK avatar Jan 30 '19 10:01 iChristosK

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.