x)- [x] bug report
- [ ] feature request
- [x] library (ng-package)
This is the process for resolving the issue in a regular angular project. However this does not seem to work for a library:
"styles": ...,
"stylePreprocessorOptions": {
"includePaths": [
"node_modules"
]
},
"scripts": ...
@import "~@material/button/mdc-button";The structure of the angular.js > library project > architect > build > options doesn't allow me to set stylePreprocessorOptions. It throws the following errors:
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(stylePreprocessorOptions).
When using @import without setting stylePreprocessorOptions:
...
Rendering Stylesheets
BUILD ERROR
File to import not found or unreadable: @material/ripple/common.
Error: File to import not found or unreadable: @material/ripple/common.
at options.error (/Users/.../Developement/jr-material-lib/node_modules/node-sass/lib/index.js:291:26)
File to import not found or unreadable: @material/ripple/common.
Error: File to import not found or unreadable: @material/ripple/common.
at options.error (/Users/.../Developement/jr-material-lib/node_modules/node-sass/lib/index.js:291:26)
...
I need a way for my library components to utilize scss styles located in node_modules
This seems to have resolved the error:
{
"name": "jr-material-lib",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
"@angular/core": "^6.0.0-rc.0 || ^6.0.0",
"@material/button": "^0.36.0"
},
"ngPackage": {
"lib": {
"styleIncludePaths": ["../../node_modules"]
}
}
}
No errors are thrown now, but no styles are actually applied to the element itself. This may be an unrelated issue so I'll post back if I find a solution.
Ok, I see the issue. The dist directory is being placed in the wrong place during the build process when "ngPackage" is used:
projects > {library-name} > dist
Rather than at the root of the project inside the appropriately named library directory:
dist > {library-name}
Manually moving the files give the desired result. Any idea why this occurs?
This seems to be an issue on the ng-packagr end, so I'm going to go ahead and close this for now. I'll move my issue over to their tracker.
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._
Most helpful comment
This seems to have resolved the error:
https://github.com/dherges/ng-packagr/blob/b401c899789aa97d369c2607116f4bcf218319e5/docs/style-include-paths.md
No errors are thrown now, but no styles are actually applied to the element itself. This may be an unrelated issue so I'll post back if I find a solution.