Skip to content

Commit 7352bcb

Browse files
clydinBrocco
authored andcommitted
test: add Angular Material stylesheet import test
1 parent aaca7d8 commit 7352bcb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
writeMultipleFiles,
3+
replaceInFile
4+
} from '../../../utils/fs';
5+
import { ng, silentNpm } from '../../../utils/process';
6+
import { stripIndents } from 'common-tags';
7+
import { updateJsonFile } from '../../../utils/project';
8+
9+
export default function () {
10+
const extensions = ['css', 'scss', 'less', 'styl'];
11+
let promise: Promise<any> = Promise.resolve()
12+
.then(() => silentNpm('install', '@angular/[email protected]'));
13+
14+
extensions.forEach(ext => {
15+
promise = promise.then(() => {
16+
return writeMultipleFiles({
17+
[`src/styles.${ext}`]: stripIndents`
18+
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
19+
`,
20+
[`src/app/app.component.${ext}`]: stripIndents`
21+
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
22+
`,
23+
})
24+
// change files to use preprocessor
25+
.then(() => updateJsonFile('.angular-cli.json', configJson => {
26+
const app = configJson['apps'][0];
27+
app['styles'] = [`styles.${ext}`];
28+
}))
29+
.then(() => replaceInFile('src/app/app.component.ts',
30+
'./app.component.css', `./app.component.${ext}`))
31+
// run build app
32+
.then(() => ng('build', '--extract-css', '--sourcemap'));
33+
});
34+
});
35+
36+
return promise;
37+
}

0 commit comments

Comments
 (0)