Skip to content

feat(sass resolve paths) #2747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/angular-cli/blueprints/ng2/files/angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"styles": [
"styles.<%= styleExt %>"
],
<% if(styleExt==='sass') { %>"sassPaths": [],<% } %>
"scripts": [],
"environments": {
"source": "environments/environment.ts",
Expand Down
4 changes: 4 additions & 0 deletions packages/angular-cli/lib/config/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface CliConfig {
* Global styles to be included in the build.
*/
styles?: string[];
/**
* includePaths array for sass import.
*/
sassPaths?: string[];
/**
* Global scripts to be included in the build.
*/
Expand Down
8 changes: 8 additions & 0 deletions packages/angular-cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
},
"additionalProperties": false
},
"sassPaths": {
"description": "includePaths array for sass import.",
"type": "array",
"items": {
"type": "string"
},
"additionalProperties": false
},
"scripts": {
"description": "Global scripts to be included in the build.",
"type": "array",
Expand Down
15 changes: 15 additions & 0 deletions packages/angular-cli/models/webpack-build-development.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const path = require('path');

import * as webpack from 'webpack';

export const getWebpackDevConfigPartial = function(projectRoot: string, appConfig: any) {
const appRoot = path.resolve(projectRoot, appConfig.root);
const sass = appConfig.sassPaths
? appConfig.sassPaths.map((includePath: string) => path.resolve(appRoot, includePath))
: [];
return {
devtool: 'cheap-module-source-map',
output: {
Expand All @@ -9,6 +15,15 @@ export const getWebpackDevConfigPartial = function(projectRoot: string, appConfi
sourceMapFilename: '[name].map',
chunkFilename: '[id].chunk.js'
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
sassLoader: {
includePaths: sass
}
}
})
],
node: {
fs: 'empty',
global: true,
Expand Down
9 changes: 8 additions & 1 deletion packages/angular-cli/models/webpack-build-production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ declare module 'webpack' {
}

export const getWebpackProdConfigPartial = function(projectRoot: string, appConfig: any) {
const appRoot = path.resolve(projectRoot, appConfig.root);
const sass = appConfig.sassPaths
? appConfig.sassPaths.map((includePath: string) => path.resolve(appRoot, includePath))
: [];
return {
devtool: 'source-map',
output: {
Expand Down Expand Up @@ -51,7 +55,10 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, appConf
},
postcss: [
require('postcss-discard-comments')
]
],
sassLoader: {
includePaths: sass
}
}
})
],
Expand Down