I have an angular library with styles that I want to use as if they were part of the application. I tried using includePaths in order to do this by using the following configuration in angular.json:
{
projects: {
"my-project": {
"root": "",
"sourceRoot": "src",
"prefix": "mp",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/selenium-agent-ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"stylePreprocessorOptions": {
"includePaths": [
"src/assets",
"node_modules/ui-library/assets"
]
},
...
In my scss style files I'd like to write the following:
@import "assets/ui-library-folder/ui-library-scss-file"
However, I'm getting the following error:
Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
1 │ @import "assets/ui-library-folder/ui-library-scss-file";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\app\app.component.scss 1:9 root stylesheet
Folder structure:
my-app
|--node_modules
| |--ui-library
| | |--assets
| | | |--ui-library-folder
| | | | |--ui-library-scss-file.scss
|--src
| |--app
| | |--app.component.scss
| |--assets
| | |--...
|--angular.json
|--package.json
|--tsconfig.json
|--tsconfig.app.json
I've tried working according to the solutions provided in these links but they do not work:
Angular 8 ignores includePaths
Shorten SCSS import path in Angular 7