-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathinclude-paths.ts
More file actions
60 lines (55 loc) · 2.22 KB
/
include-paths.ts
File metadata and controls
60 lines (55 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { writeMultipleFiles, expectFileToMatch, replaceInFile, createDir } from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';
export default async function () {
await createDir('src/style-paths');
await writeMultipleFiles({
'src/style-paths/_variables.scss': '$primary-color: red;',
'src/styles.scss': `
@import 'variables';
h1 { color: $primary-color; }
`,
'src/app/app.scss': `
@import 'variables';
h2 { color: $primary-color; }
`,
'src/style-paths/variables.less': '@primary-color: #ADDADD;',
'src/styles.less': `
@import 'variables';
h5 { color: @primary-color; }
`,
'src/app/app.less': `
@import 'variables';
h6 { color: @primary-color; }
`,
});
await replaceInFile(
'src/app/app.ts',
`styleUrl: './app.css\'`,
`styleUrls: ['./app.scss', './app.less']`,
);
await updateJsonFile('angular.json', (workspaceJson) => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.scss' },
{ input: 'src/styles.less' },
];
appArchitect.build.options.stylePreprocessorOptions = {
includePaths: ['src/style-paths'],
};
});
await ng('build', '--configuration=development');
await expectFileToMatch('dist/test-project/browser/styles.css', /h1\s*{\s*color: red;\s*}/);
await expectFileToMatch('dist/test-project/browser/main.js', /h2.*{.*color: red;.*}/);
// These checks are for the less files
await expectFileToMatch('dist/test-project/browser/styles.css', /h5\s*{\s*color: #ADDADD;\s*}/);
await expectFileToMatch('dist/test-project/browser/main.js', /h6.*{.*color: #ADDADD;.*}/);
await ng('build', '--no-aot', '--configuration=development');
await expectFileToMatch('dist/test-project/browser/styles.css', /h1\s*{\s*color: red;\s*}/);
await expectFileToMatch('dist/test-project/browser/main.js', /h2.*{[\S\s]*color: red;[\S\s]*}/);
await expectFileToMatch('dist/test-project/browser/styles.css', /h5\s*{\s*color: #ADDADD;\s*}/);
await expectFileToMatch(
'dist/test-project/browser/main.js',
/h6.*{[\S\s]*color: #ADDADD;[\S\s]*}/,
);
}