I was wondering if there is anyway to add path mapping for SASS files in Angular 4? What I mean is, lets say I have global scss files stored in src/assets/styles and I would like to access these files in my component scss files which are stored in src/app/component/{component-name}/{component-name}.component.scss. Currently I have to do:
@import "../../../assets/styles/{file-needed}.scss";
When I would like to be able to do something like:
@import "~assets/styles/{file-needed}.scss";
I know the ~ will go to the node_modules dir, that's just an example. Is there anyway to create a shortcut for these kind of things?
Many thanks in advance!
I found the answer. You can add "stylePreprocessorOptions" to the angular-cli.json app object to include any path in your scss compilation. Source is here .
update 2019
In Angular 6 and newer, in angular.json
"projects": {
"projectName": {
...
"architect": {
"build": {
...
"options": {
...
"stylePreprocessorOptions": {
"includePaths": [
"node_modules",
"src/app/styles",
"some/other/path/to/scss"
]
},
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.