Skip to content

Commit d47b441

Browse files
committed
feat(@angular-devkit/build-angular): support processing component inline CSS styles
The internal Webpack configuration now includes support for style rules with MIME type conditions. This allows the data URIs generated for inline component CSS styles by the Angular Webpack plugin to be processed with the same loaders as file based styles.
1 parent 8c7d56e commit d47b441

File tree

5 files changed

+214
-132
lines changed

5 files changed

+214
-132
lines changed

packages/angular_devkit/build_angular/src/browser/specs/styles_spec.ts

+52-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,56 @@ describe('Browser Builder styles', () => {
124124
await browserBuild(architect, host, target, { extractCss: true });
125125
});
126126

127+
it('supports autoprefixer with inline component styles in JIT mode', async () => {
128+
host.writeMultipleFiles({
129+
'./src/app/app.component.ts': `
130+
import { Component } from '@angular/core';
131+
132+
@Component({
133+
selector: 'app-root',
134+
templateUrl: './app.component.html',
135+
styles: ['div { flex: 1 }'],
136+
})
137+
export class AppComponent {
138+
title = 'app';
139+
}
140+
`,
141+
'.browserslistrc': 'IE 10',
142+
});
143+
144+
// Set target to ES5 to avoid differential loading and unnecessary testing time
145+
host.replaceInFile('tsconfig.json', '"target": "es2017"', '"target": "es5"');
146+
147+
const { files } = await browserBuild(architect, host, target, { aot: false });
148+
149+
expect(await files['main.js']).toContain('-ms-flex: 1;');
150+
});
151+
152+
it('supports autoprefixer with inline component styles in AOT mode', async () => {
153+
host.writeMultipleFiles({
154+
'./src/app/app.component.ts': `
155+
import { Component } from '@angular/core';
156+
157+
@Component({
158+
selector: 'app-root',
159+
templateUrl: './app.component.html',
160+
styles: ['div { flex: 1 }'],
161+
})
162+
export class AppComponent {
163+
title = 'app';
164+
}
165+
`,
166+
'.browserslistrc': 'IE 10',
167+
});
168+
169+
// Set target to ES5 to avoid differential loading and unnecessary testing time
170+
host.replaceInFile('tsconfig.json', '"target": "es2017"', '"target": "es5"');
171+
172+
const { files } = await browserBuild(architect, host, target, { aot: true });
173+
174+
expect(await files['main.js']).toContain('-ms-flex: 1;');
175+
});
176+
127177
extensionsWithImportSupport.forEach(ext => {
128178
it(`supports imports in ${ext} files`, async () => {
129179
host.writeMultipleFiles({
@@ -456,7 +506,8 @@ describe('Browser Builder styles', () => {
456506
main = await files['main.js'];
457507
expect(styles).toContain(`url('/assets/global-img-absolute.svg')`);
458508
expect(main).toContain(`url('/assets/component-img-absolute.svg')`);
459-
});
509+
// NOTE: Timeout for large amount of builds in test. Test should be split up when refactored.
510+
}, 4 * 60 * 1000);
460511

461512
it(`supports bootstrap@4 with full path`, async () => {
462513
const bootstrapPath = dirname(require.resolve('bootstrap/package.json'));

0 commit comments

Comments
 (0)