Ng-packagr: Use sass files from node_modules

Created on 15 Jan 2018  路  5Comments  路  Source: ng-packagr/ng-packagr

Type of Issue

[ ] Bug Report
[ ] Feature Request
[ x ] Question

Description

Hi! I'm new with all of theses technologies and I'm facing with one problem:

  • I have an Angular project where I'm using a styles libraries.
  • The configuration that I made to use this library on my angular-cli.json is:

... "styles": [ "../node_modules/styles/dist/styles.scss" ], "stylePreprocessorOptions": { "includePaths": [ "../node_modules/styles/dist" ] }, ...

With this, I'm importing the styles on my component like:
file: foo.components.scss

@import "styles"

.foo{
...
}

This works but when I'm trying to package my code, it throws an error related to that import:

console output:

Building Angular library
Generating bundle for test
Cleaning bundle build directory
Processing assets
BUILD ERROR
File to import not found or unreadable: styles.
Error: File to import not found or unreadable: styles.

So I think that I need to specify to packagr where can find that file as I'm doing with my angular-cli.json...

Is there any way to do that? or maybe I'm wrong with my configurations?

This is my ng-package.json:

{ "$schema": "./node_modules/ng-packagr/ng-package.schema.json", "lib": { "cssUrl": "inline" ], "entryFile": "index.ts", } }

Version Information

ng-packagr: 1.6.0
@angular/*: 5.0.0
typescript: 2.6.1
rxjs: 5.5.2
node: 8.9.1
npm: 5.2.0

Most helpful comment

Hi @mwootendev!

I tried using ~ operator and its working!

Thanks for your help!

All 5 comments

@alankyn I believe your question is already addressed in issue #282. I have had the same issue. Currently there is not support for additional SASS include paths, but I have opened pull request #494 that should hopefully add support for this feature.

@alankyn Actually, I believe support for loading styles from node_modules is already supported using the ~ operator. You may be able to change your import to @import '~styles/dist/styles' to reference that path.

Hi @mwootendev !!

Thanks for your reply. I will try it.

Really, thank you so much!

Hi @mwootendev!

I tried using ~ operator and its working!

Thanks for your help!

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

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings