stylePreprocessorOptions.includePathts Configuration isn't working with Sass

See original GitHub issue

I’ve setup the stylePreprocessorOptions.includePathts configuration to include my Bower components and the settings are ignored.

OS?

macOS Sierra (v10.12.3)

Versions.

@angular/cli: 1.0.0-rc.0

Repro steps.

Added Bower Package Manager

The log given by the failure.

ERROR in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module build failed:
@import '~foundation';
^
      File to import not found or unreadable: ~foundation.
Parent style sheet: stdin
      in /data/src/styles.scss (line 5, column 1)
 @ ./src/styles.scss 4:14-195
 @ multi ./src/styles.scss
webpack: Failed to compile.
webpack: Compiling...
Hash: f2223248bed1092fe792
Time: 2038ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 153 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 175 kB {3} [initial]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 8.4 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.46 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]

Mention any other details that might be useful.

.angular-cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "quickstart"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "starfish",
      "styles": [
        "styles.scss"
      ],
      "stylePreprocessorOptions": {
        "includePaths": [
          "src/bower_components/foundation-sites/scss"
        ]
      },
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "scss",
    "component": {}
  }
}

The important part is:

"stylePreprocessorOptions": {
        "includePaths": [
          "src/bower_components/foundation-sites/scss"
        ]
      },

./src/styles.scss

@charset "utf-8";

@import 'foundation';

The Bower files are found in ./src/bower_components

It seems like the configuration is incorrect or the compiler is ignore these settings and is unable to resolve the Sass file (foundation).

Please help, thanks!


p.s. I’m able to compile using the relative paths, but:

@import 'bower_components/foundation-sites/scss/foundation';

is not as readable as:

@import foundation

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nicky-lenaerscommented, Mar 7, 2017

Any updates on this one? Having a similar issue

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

stylePreprocessorOptions includePaths do not work in 6.0.0 ...
Desired behavior. This type of SCSS/Sass import should work out of the box.
Read more >
stylePreprocessorOptions not working on @Angular/cli 7
I've found the problem. I was loading themes/client-X instead of src/themes/client-X inside the angular.json .
Read more >
SASS "includePaths" in angular.json is not recognized when ...
The problem is next: I have an Angular monorepo project. I've set projects.public.architect.build.options.stylePreprocessorOptions.includePaths to be ...
Read more >
Using Sass with the Angular CLI - DigitalOcean
Use the ~ to import Sass files in Angular CLI projects. ... we can specify the includePaths configuration when working with the CLI....
Read more >
Angular workspace configuration
Style preprocessor options link. In Sass you can make use of the includePaths feature for both component and global styles. This allows you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found