|
| 1 | +import { |
| 2 | + deleteFile, |
| 3 | + expectFileToMatch, |
| 4 | + replaceInFile, |
| 5 | + writeMultipleFiles, |
| 6 | +} from '../../../utils/fs'; |
| 7 | +import { ng, silentExec, silentNpm } from '../../../utils/process'; |
| 8 | +import { updateJsonFile } from '../../../utils/project'; |
| 9 | +import { expectToFail } from '../../../utils/utils'; |
| 10 | + |
| 11 | + |
| 12 | +export default async function () { |
| 13 | + if (process.platform.startsWith('win')) { |
| 14 | + return; |
| 15 | + } |
| 16 | + |
| 17 | + await writeMultipleFiles({ |
| 18 | + 'src/styles.scss': '@import \'./imported-styles.scss\';\nbody { background-color: blue; }', |
| 19 | + 'src/imported-styles.scss': 'p { background-color: red; }', |
| 20 | + 'src/app/app.component.scss': '.outer { .inner { background: #fff; } }', |
| 21 | + }); |
| 22 | + await deleteFile('src/app/app.component.css'); |
| 23 | + await updateJsonFile('angular.json', workspaceJson => { |
| 24 | + const appArchitect = workspaceJson.projects['test-project'].targets; |
| 25 | + appArchitect.build.options.styles = [ |
| 26 | + { input: 'src/styles.scss' }, |
| 27 | + ]; |
| 28 | + }); |
| 29 | + await replaceInFile('src/app/app.component.ts', './app.component.css', './app.component.scss'); |
| 30 | + |
| 31 | + await silentExec('rm', '-rf', 'node_modules/node-sass'); |
| 32 | + await expectToFail(() => ng('build', '--extract-css', '--source-map')); |
| 33 | + |
| 34 | + await silentNpm('install', 'sass'); |
| 35 | + await silentExec('rm', '-rf', 'node_modules/node-sass'); |
| 36 | + await ng('build', '--extract-css', '--source-map'); |
| 37 | + |
| 38 | + await expectFileToMatch('dist/test-project/styles.css', /body\s*{\s*background-color: blue;\s*}/); |
| 39 | + await expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/); |
| 40 | + await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""')); |
| 41 | + await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/); |
| 42 | + |
| 43 | + await silentNpm('install', 'node-gyp'); |
| 44 | + await silentNpm('install', 'fibers'); |
| 45 | + await silentExec('rm', '-rf', 'node_modules/node-sass'); |
| 46 | + await ng('build', '--extract-css', '--source-map'); |
| 47 | + |
| 48 | + await expectFileToMatch('dist/test-project/styles.css', /body\s*{\s*background-color: blue;\s*}/); |
| 49 | + await expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/); |
| 50 | + await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""')); |
| 51 | + await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/); |
| 52 | +} |
0 commit comments