Skip to content

Commit 8afe09d

Browse files
committed
feat(sass resolve paths) change webpack config to implement sassLoader's includePaths support
1 parent b57d1bd commit 8afe09d

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

packages/angular-cli/blueprints/ng2/files/angular-cli.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"styles": [
2121
"styles.<%= styleExt %>"
2222
],
23+
<% if(styleExt==='sass') { %>"sassPaths": [],<% } %>
2324
"scripts": [],
2425
"environments": {
2526
"source": "environments/environment.ts",

packages/angular-cli/lib/config/schema.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export interface CliConfig {
2323
* Global styles to be included in the build.
2424
*/
2525
styles?: string[];
26+
/**
27+
* includePaths array for sass import.
28+
*/
29+
sassPaths?: string[];
2630
/**
2731
* Global scripts to be included in the build.
2832
*/

packages/angular-cli/lib/config/schema.json

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@
6666
},
6767
"additionalProperties": false
6868
},
69+
"sassPaths": {
70+
"description": "includePaths array for sass import.",
71+
"type": "array",
72+
"items": {
73+
"type": "string"
74+
},
75+
"additionalProperties": false
76+
},
6977
"scripts": {
7078
"description": "Global scripts to be included in the build.",
7179
"type": "array",

packages/angular-cli/models/webpack-build-development.ts

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ declare module 'webpack' {
1313
};
1414

1515
export const getWebpackDevConfigPartial = function(projectRoot: string, appConfig: any) {
16+
const appRoot = path.resolve(projectRoot, appConfig.root);
17+
const sass = appConfig.sassPaths
18+
? appConfig.sassPaths.map((includePath: string) => path.resolve(appRoot, includePath))
19+
: [];
1620
return {
1721
devtool: 'cheap-module-source-map',
1822
output: {
@@ -29,6 +33,9 @@ export const getWebpackDevConfigPartial = function(projectRoot: string, appConfi
2933
failOnHint: false,
3034
resourcePath: path.resolve(projectRoot, appConfig.root)
3135
},
36+
sassLoader: {
37+
includePaths: sass
38+
}
3239
}
3340
})
3441
],

packages/angular-cli/models/webpack-build-production.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ const CompressionPlugin = require('compression-webpack-plugin');
44
import * as webpack from 'webpack';
55

66
export const getWebpackProdConfigPartial = function(projectRoot: string, appConfig: any) {
7+
const appRoot = path.resolve(projectRoot, appConfig.root);
8+
const sass = appConfig.sassPaths
9+
? appConfig.sassPaths.map((includePath: string) => path.resolve(appRoot, includePath))
10+
: [];
711
return {
812
devtool: 'source-map',
913
output: {
@@ -46,7 +50,10 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, appConf
4650
},
4751
postcss: [
4852
require('postcss-discard-comments')
49-
]
53+
],
54+
sassLoader: {
55+
includePaths: sass
56+
}
5057
}
5158
})
5259
],

0 commit comments

Comments
 (0)