mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 11:44:05 +08:00
fix(@angular-devkit/build-angular): bring back style tags in browser builder
This commit is contained in:
parent
2e43ec6654
commit
d746de59f3
@ -200,5 +200,60 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
|
|||||||
|
|
||||||
harness.expectFile('dist/browser/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
|
harness.expectFile('dist/browser/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add prefixes for listed browsers in inline template styles', async () => {
|
||||||
|
await harness.writeFile(
|
||||||
|
'.browserslistrc',
|
||||||
|
`
|
||||||
|
Safari 15.4
|
||||||
|
Edge 104
|
||||||
|
Firefox 91
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await harness.modifyFile('src/app/app.component.ts', (content) => {
|
||||||
|
return content.replace('styleUrls', 'styles').replace('./app.component.css', '');
|
||||||
|
});
|
||||||
|
await harness.modifyFile('src/app/app.component.html', (content) => {
|
||||||
|
return `<style>aside { hyphens: none; }</style>\n${content}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
harness.useTarget('build', {
|
||||||
|
...BASE_OPTIONS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { result } = await harness.executeOnce();
|
||||||
|
expect(result?.success).toBeTrue();
|
||||||
|
|
||||||
|
harness
|
||||||
|
.expectFile('dist/browser/main.js')
|
||||||
|
// div[_ngcontent-%COMP%] {\n -webkit-hyphens: none;\n hyphens: none;\n}\n
|
||||||
|
.content.toMatch(/{\\n\s*-webkit-hyphens:\s*none;\\n\s*hyphens:\s*none;\\n\s*}/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add prefixes if not required by browsers in inline template styles', async () => {
|
||||||
|
await harness.writeFile(
|
||||||
|
'.browserslistrc',
|
||||||
|
`
|
||||||
|
Edge 110
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await harness.modifyFile('src/app/app.component.ts', (content) => {
|
||||||
|
return content.replace('styleUrls', 'styles').replace('./app.component.css', '');
|
||||||
|
});
|
||||||
|
await harness.modifyFile('src/app/app.component.html', (content) => {
|
||||||
|
return `<style>aside { hyphens: none; }</style>\n${content}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
harness.useTarget('build', {
|
||||||
|
...BASE_OPTIONS,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { result } = await harness.executeOnce();
|
||||||
|
expect(result?.success).toBeTrue();
|
||||||
|
|
||||||
|
harness.expectFile('dist/browser/main.js').content.toMatch(/{\\n\s*hyphens:\s*none;\\n\s*}/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -140,6 +140,37 @@ describe('Browser Builder styles', () => {
|
|||||||
expect(await files['main.js']).toContain('-webkit-mask-composite');
|
expect(await files['main.js']).toContain('-webkit-mask-composite');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('supports autoprefixer with inline template styles in AOT mode', async () => {
|
||||||
|
host.writeMultipleFiles({
|
||||||
|
'./src/app/app.component.html': `
|
||||||
|
<style>div { mask-composite: add; }</style>
|
||||||
|
<div>{{ title }}</div>
|
||||||
|
`,
|
||||||
|
'./src/app/app.component.ts': `
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-root',
|
||||||
|
standalone: false,
|
||||||
|
templateUrl: './app.component.html',
|
||||||
|
styles: 'div { font-weight: 500; }',
|
||||||
|
})
|
||||||
|
export class AppComponent {
|
||||||
|
title = 'app';
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
'.browserslistrc': `
|
||||||
|
Safari 15.4
|
||||||
|
Edge 104
|
||||||
|
Firefox 91
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { files } = await browserBuild(architect, host, target, { aot: true });
|
||||||
|
|
||||||
|
expect(await files['main.js']).toContain('-webkit-mask-composite');
|
||||||
|
});
|
||||||
|
|
||||||
extensionsWithImportSupport.forEach((ext) => {
|
extensionsWithImportSupport.forEach((ext) => {
|
||||||
it(`supports imports in ${ext} files`, async () => {
|
it(`supports imports in ${ext} files`, async () => {
|
||||||
host.writeMultipleFiles({
|
host.writeMultipleFiles({
|
||||||
|
@ -38,7 +38,7 @@ export function augmentHostWithResources(
|
|||||||
|
|
||||||
resourceLoader.setAffectedResources(filePath, [filePath]);
|
resourceLoader.setAffectedResources(filePath, [filePath]);
|
||||||
|
|
||||||
return content;
|
return Promise.resolve(content);
|
||||||
} else {
|
} else {
|
||||||
return resourceLoader.get(filePath);
|
return resourceLoader.get(filePath);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user