Skip to content

Commit 60ad834

Browse files
JPeer264dond2clouds
authored andcommitted
feat(@angular/cli): support includePaths for less (closes angular#7083)
1 parent 6c607ec commit 60ad834

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

packages/@angular/cli/models/webpack-configs/styles.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
135135
{ test: /\.less$/, use: [{
136136
loader: 'less-loader',
137137
options: {
138-
sourceMap: cssSourceMap
138+
sourceMap: cssSourceMap,
139+
paths: includePaths
139140
}
140141
}]
141142
},

tests/e2e/tests/build/styles/include-paths.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,25 @@ export default function () {
3030
@import 'variables'
3131
h4
3232
background-color: $primary-color
33+
`,
34+
'src/style-paths/variables.less': '@primary-color: #ADD;',
35+
'src/styles.less': `
36+
@import 'variables';
37+
h5 { color: @primary-color; }
38+
`,
39+
'src/app/app.component.less': `
40+
@import 'variables';
41+
h6 { color: @primary-color; }
3342
`
3443
}))
3544
.then(() => replaceInFile('src/app/app.component.ts', `'./app.component.css\'`,
36-
`'./app.component.scss', './app.component.styl'`))
45+
`'./app.component.scss', './app.component.styl', './app.component.less'`))
3746
.then(() => updateJsonFile('.angular-cli.json', configJson => {
3847
const app = configJson['apps'][0];
3948
app['styles'] = [
4049
'styles.scss',
41-
'styles.styl'
50+
'styles.styl',
51+
'styles.less'
4252
];
4353
app['stylePreprocessorOptions'] = {
4454
includePaths: [
@@ -52,9 +62,13 @@ export default function () {
5262
.then(() => expectFileToMatch('dist/main.bundle.js', /h2.*{.*color: red;.*}/))
5363
.then(() => expectFileToMatch('dist/styles.bundle.css', /h3\s*{\s*color: #008000;\s*}/))
5464
.then(() => expectFileToMatch('dist/main.bundle.js', /h4.*{.*color: #008000;.*}/))
65+
.then(() => expectFileToMatch('dist/styles.bundle.css', /h5\s*{\s*color: #ADDADD;\s*}/))
66+
.then(() => expectFileToMatch('dist/main.bundle.js', /h6.*{.*color: #ADDADD;.*}/))
5567
.then(() => ng('build', '--extract-css', '--aot'))
5668
.then(() => expectFileToMatch('dist/styles.bundle.css', /h1\s*{\s*color: red;\s*}/))
5769
.then(() => expectFileToMatch('dist/main.bundle.js', /h2.*{.*color: red;.*}/))
5870
.then(() => expectFileToMatch('dist/styles.bundle.css', /h3\s*{\s*color: #008000;\s*}/))
59-
.then(() => expectFileToMatch('dist/main.bundle.js', /h4.*{.*color: #008000;.*}/));
71+
.then(() => expectFileToMatch('dist/main.bundle.js', /h4.*{.*color: #008000;.*}/))
72+
.then(() => expectFileToMatch('dist/styles.bundle.css', /h5\s*{\s*color: #ADDADD;\s*}/))
73+
.then(() => expectFileToMatch('dist/main.bundle.js', /h6.*{.*color: #ADDADD;.*}/));
6074
}

0 commit comments

Comments
 (0)