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

For everyone still having issues with unquoted url functions, a fix has been merged in master (#9738) and will be available in 1.7.2 which will be released this week.

clydin avatar Feb 26 '18 17:02 clydin

Still having the issue with 1.7.2 My file:


@font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url('MaterialIcons-Regular.eot'); /* For IE6-8 */
    src: local('Material Icons'),
    local('MaterialIcons-Regular'),
    url('MaterialIcons-Regular.woff2') format('woff2'),
    url('MaterialIcons-Regular.woff') format('woff'),
    url('MaterialIcons-Regular.ttf') format('truetype');
}

.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px; /* Preferred icon size */
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;

    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;

    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;

    /* Support for IE. */
    font-feature-settings: 'liga';
}

Polyterative avatar Mar 05 '18 10:03 Polyterative

@Polyterative Try targeting es5 in your ts file. It solved my problem, but it's not a long term solution.

krilllind avatar Mar 05 '18 11:03 krilllind

Solved by calling containing folder Material_IconFont instead of Material IconFont. In my case the space was causing issues

Polyterative avatar Mar 06 '18 12:03 Polyterative

I'm having the same issue :-(

lenichols avatar Mar 06 '18 19:03 lenichols

@Polyterative Yea, you can not have any spaces in your url, especially if you have unquoted uses.

krilllind avatar Mar 06 '18 19:03 krilllind

im having the same issue:

ERROR in ./src/app/cemex/cmx_dropdown/components/dropdown-item/cmx-dropdown-item.component.scss (Emitted value instead of an instance of Error) CssSyntaxError: C:\Users\irwin\Documents\Projectos\TestCEMEX\src\app\cemex\cmx_dropdown\assets\scss_font-icons.scss:15:8: Can't resolve './../fonts/dls-icons.svg' in 'C:\Users\irwin\Documents\Projectos\TestCEMEX\src\app\cemex\cmx_dropdown\components\dropdown-item'

the code i have is this

src: url('./../fonts/dls-icons.eot'); src: url('./../fonts/dls-icons.eot') format('embedded-opentype'), url('./../fonts/dls-icons.ttf') format('truetype'), url('./../fonts/dls-icons.woff') format('woff'), url('./../fonts/dls-icons.svg') format('svg');

Xiurik avatar Mar 06 '18 21:03 Xiurik

Try removing "-" in urls. If that does not solve the problem, we might still have an issue with svg.

krilllind avatar Mar 06 '18 21:03 krilllind

I changed the name and then still problem.

**ERROR in ./src/app/cemex/cmx_dropdown/components/dropdown-item/cmx-dropdown-item.component.scss (Emitted value instead of an instance of Error) CssSyntaxError: C:\Users\irwin\Documents\Projectos\TestCEMEX\src\app\cemex\cmx_dropdown\assets\scss_font-icons.scss:12:7: Can't resolve './../fonts/icons.woff' in 'C:\Users\irwin\Documents\Projectos\TestCEMEX\src\app\cemex\cmx_dropdown\components\dropdown-item'

10 | 11 |

12 | src: url('./../fonts/icons.woff') format('woff');**

my code is

@font-face { font-family: 'dls-icons'; url('./../fonts/icons.woff') format('woff'); font-weight: normal; font-style: normal; }

Xiurik avatar Mar 06 '18 21:03 Xiurik

The folder "fonts", is it included in angular-cli.json file as a static folder?

You can navigate to localhost:4000/webpack-dev-server to see if your targeting folder was correctly emitted and if your given don't url points to that folder.

krilllind avatar Mar 06 '18 22:03 krilllind

The problem I'm currently having looks much like this issue. Here's the output

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
Module build failed: Error: Can't resolve 'node_modules/font-awesome/css/font-awesome.css'

deksprime avatar Mar 06 '18 22:03 deksprime

this one doesnt show anything: localhost:4000/webpack-dev-server

and did a downgrade to 1.7.0 and still having the problem.

IDK what you mean with this: The folder "fonts", is it included in angular-cli.json file as a static folder

where do i add this folder and how?? any example please??

Xiurik avatar Mar 06 '18 22:03 Xiurik

When running my serve you can view the output in the browser by navigating to localhost:4000/webpack-dev-server (or another port if you have changed it).

Yes, in the included angular-cli.json file, you can add the name of your folder in quotes to tell angular not to bundle these file (leave as is). More information about this can be found here https://github.com/angular/angular-cli/wiki/angular-cli

krilllind avatar Mar 06 '18 22:03 krilllind

If your case, you might have to add "fonts" To the apps -> assets array

krilllind avatar Mar 06 '18 22:03 krilllind

Im getting this too, and I have no SVGs. Worked fine in 1.6.0. Not working in 1.7.3.

The error is misleading, as it says it cannot find a variable $primary which is indeed in my styles folder.

ERROR in ./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./src/styles/styles.scss
Module build failed:
  $primary-color: map-get($primary, 400);
                         ^
      Undefined variable: "$primary".
      in /Users/papa/_git/ngrx-data-lab/src/styles/mixin.scss (line 8, column 27)

I created a new issue for this #9928

johnpapa avatar Mar 10 '18 14:03 johnpapa

Is there an actual fix for this? Still not working for me with 1.7.3.

ORIGINALUSRNM avatar Mar 15 '18 05:03 ORIGINALUSRNM

Still getting this error in 1.7.3

ERROR in ./src/app/app.component.css (Emitted value instead of an instance of Error) CssSyntaxError: C:\Users\XXXXXX\Documents\WebStorm\Admin\src\assets\css\theme-default.css:771:26: Can't resolve '../img/logo-small.png' in 'C:\Users\SSSSSS\Documents\WebStorm\Admin\src\app'

kolexinfos avatar Mar 22 '18 16:03 kolexinfos

@johnpapa @kolexinfos @ORIGINALUSRNM Probably same as this: https://github.com/angular/angular-cli/issues/9943

You need to lock your node-sass

hccampos avatar Mar 22 '18 19:03 hccampos

My issue was not with node-sass was with the version of webpack that is in use at the time.

The @angular/[email protected] uses [email protected] which does not recognize.

I had to downgrade to @angular/[email protected] which uses @[email protected] which built the project successfully.

kolexinfos avatar Mar 28 '18 12:03 kolexinfos

I'm on @angular/cli 1.7.4 and I've had the same issue while I was trying to load fonts.

I fixed the problem by assigning url value to scss variable, hope it helps!

$font_src-bold: url("./assets/fonts/SF-UI-Display-Bold.otf");

@font-face {
    font-family: "SF Pro Display";
    font-weight: 700;
    src: $font_src-bold;
}

filipwiniarski avatar Apr 19 '18 14:04 filipwiniarski