-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathscss-legacy.ts
55 lines (49 loc) · 1.73 KB
/
scss-legacy.ts
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
import {
writeMultipleFiles,
deleteFile,
expectFileToMatch,
replaceInFile,
} from '../../../utils/fs';
import { expectToFail } from '../../../utils/utils';
import { execWithEnv } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';
import assert from 'assert';
export default async function () {
await writeMultipleFiles({
'src/styles.scss': `
@import './imported-styles.scss';
body { background-color: blue; }
`,
'src/imported-styles.scss': 'p { background-color: red; }',
'src/app/app.component.scss': `
.outer {
.inner {
background: #fff;
}
}
`,
});
await updateJsonFile('angular.json', (workspaceJson) => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [{ input: 'src/styles.scss' }];
});
await deleteFile('src/app/app.component.css');
await replaceInFile('src/app/app.component.ts', './app.component.css', './app.component.scss');
const { stderr } = await execWithEnv(
'ng',
['build', '--source-map', '--configuration=development'],
{
...process.env,
NG_BUILD_LEGACY_SASS: '1',
},
);
assert.match(
stderr,
/Warning: 'NG_BUILD_LEGACY_SASS'/,
`Expected stderr to contain 'NG_BUILD_LEGACY_SASS' usage warning`,
);
await expectFileToMatch('dist/test-project/styles.css', /body\s*{\s*background-color: blue;\s*}/);
await expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/);
await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""'));
await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/);
}