angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Import less file from node_modules in angular library is not working

Open d-bechtel opened this issue 8 years ago • 3 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [x] build
- [x] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

npm 6.3.0 node 10.8.0 angular-cli: 6.1.2 windows 7

Repro steps

  • create new project: ng new my-app
  • go into dir: cd my-app
  • generate library: ng generate library my-lib
  • create a component in my-lib with less stylesheet (my-lib.component.less).
  • import some less file from npm in my-lib.component.less: @import (reference) "~some-module/path/to/file.less"; ...
  • build library with: ng build my-lib

The log given by the failure

BUILD ERROR '~some-module/path/to/file.less' wasn't found. Tried ...

Desired functionality

importing some third party styles should work. It seems that ng-packagr adds also the prefix ~ or npm:// to this import.

Mention any other details that might be useful

if i remove the ~ from the import statement, ng build my-lib works as expected. But ng test my-lib doesn't work anymore, because ng test my-lib needs the ~ in the import statement.

d-bechtel avatar Aug 02 '18 11:08 d-bechtel

ng-packagr only support relative ~ import syntax for SCSS files.

https://github.com/dherges/ng-packagr/issues/827 https://github.com/dherges/ng-packagr/issues/227

alan-agius4 avatar Aug 02 '18 13:08 alan-agius4

Closing as answered by @alan-agius4, cheers!

filipesilva avatar Aug 02 '18 17:08 filipesilva

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.