Skip to content

stylePreprocessorOptions includePaths do not work in 6.0.0-beta.6 #10007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
euangoddard opened this issue Mar 19, 2018 · 14 comments
Closed

stylePreprocessorOptions includePaths do not work in 6.0.0-beta.6 #10007

euangoddard opened this issue Mar 19, 2018 · 14 comments

Comments

@euangoddard
Copy link

euangoddard commented Mar 19, 2018

Versions

@angular/cli: 6.0.0-beta.6
@angular-devkit/architect: 0.0.7
@angular-devkit/build-optimizer: 0.4.6
@angular-devkit/build-webpack: 0.0.7
@angular-devkit/core: 0.4.6
@angular-devkit/schematics: 0.4.6
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 6.0.0-beta.6
@schematics/angular: 0.4.6
@schematics/package-update: 0.4.6
typescript: 2.7.2
webpack: 4.1.1

Repro steps

  • Set up a brand new CLI project using ng new --next ng6
  • Configure the files as per this E2E test

Observed behavior

ERROR in ../node_modules/@angular-devkit/build-webpack/src/angular-cli-files/plugins/raw-css-loader.js!../node_modules/postcss-loader/lib??embedded!../node_modules/sass-loader/lib/loader.js??ref--14-3!./styles.scss
Module build failed: 
@import "variables";
^
      File to import not found or unreadable: variables.
Parent style sheet: stdin
      in /Users/euan/Sites/ng6/src/styles.scss (line 2, column 1)

Desired behavior

This type of SCSS/Sass import should work out of the box.

@sandangel
Copy link

same here, changed to relative path but it doesnt work too

@BhaskaranR
Copy link

BhaskaranR commented Apr 4, 2018

worked for me. check if the root is empty and change

 "stylePreprocessorOptions": {
              "includePaths": [
                "./"
              ]
            },

to

 "stylePreprocessorOptions": {
              "includePaths": [
                "./src"
              ]
            },

@alexciesielski
Copy link

alexciesielski commented Apr 10, 2018

Where in angular.json do you guys add the stylePreprocessorOptions?

@sandangel
Copy link

sandangel commented Apr 10, 2018

@ciesielskico you should add it like this

            "styles": [
              {
                "input": "src/styles.scss"
              },
              {
                "input": "node_modules/bootstrap/scss/bootstrap.scss"
              }
            ],
            "stylePreprocessorOptions": {
              "includePaths": ["./src", "./folder/you/want/to/include"]
            },
            "scripts": []

@euangoddard
Copy link
Author

@sandangel that works fine. It looks like this has been fixed now

@MickL
Copy link

MickL commented Apr 30, 2018

@sandangel Don't add ./:

"stylePreprocessorOptions": {
"includePaths": ["src", "folder/you/want/to/include"]
},

@bellizio
Copy link

bellizio commented May 7, 2018

I'm having the same issue after upgrading to version 6. I've tried everything noted here and in the other related issues (#10036, #10473) for this bug, but have not had any luck.

In my case, I am importing a variables.scss file in a number of component files, so the error is something like the following:

ERROR in Module build failed:
@import 'variables';
^
      File to import not found or unreadable: variables.
      in /ng6/src/app/home/home.component.scss (line 1, column 1)

Update: I was missing stylePreprocessorOptions in my server app config. My app is using server-side rendering via angular universal, so stylePreprocessorOptions is required in the build 'options' there as well.

@christo8989
Copy link

I was getting this error on ng test and @bellizio 's comment made me realize I was missing the stylePreprocessorOptions inside that part of the configuration.

@Askiater
Copy link

@MickL For me it works in both ways.
Like this:
"stylePreprocessorOptions": { "includePaths": [ "src/", "src/styles/" ]
And like this also:
"stylePreprocessorOptions": { "includePaths": [ "./src/", "./src/styles/" ]

@jderus
Copy link

jderus commented Jun 20, 2018

Just wanted to add that if you may need to kill and restart the ng serve process if the stylePreprocessorOptions workaround is not working for you.

@tahiryasin
Copy link

tahiryasin commented Apr 16, 2019

I'm having the same issue after upgrading to version 6. I've tried everything noted here and in the other related issues (#10036, #10473) for this bug, but have not had any luck.

In my case, I am importing a variables.scss file in a number of component files, so the error is something like the following:

ERROR in Module build failed:
@import 'variables';
^
      File to import not found or unreadable: variables.
      in /ng6/src/app/home/home.component.scss (line 1, column 1)

Update: I was missing stylePreprocessorOptions in my server app config. My app is using server-side rendering via angular universal, so stylePreprocessorOptions is required in the build 'options' there as well.

Could anyone please tell me how can I add stylePreprocessorOptions in build options?

My angular.json looks like

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/browser",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "stylePreprocessorOptions": {
              "includePaths": [
                "src"
              ]
            },
...
...

@ArthurianX
Copy link

Just upgraded from @angular-cli 8.0.2 to 8.2.0 and this isn't working anymore.

I have no example as the codebase is huge, the only gotcha is that in an scss project I was including paths for sass files and it worked.

If I add the full path it still works so I believe it's something from the new version, or is it ?
Anyone else?

@ninjaxelite
Copy link

Finally it works!! - Angular: 8.2.2

src/stylings/_mixins.scss

"stylePreprocessorOptions": {
    "includePaths": [
        "src/", "src/stylings/
     ]
}

@import "mixins";

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests