mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 19:13:34 +08:00
fix(@angular-devkit/build-angular): properly handle comment removal during font inlining
Closes #19350
This commit is contained in:
parent
313c3f2340
commit
1237ddacea
@ -159,10 +159,10 @@ export class InlineFontsProcessor {
|
|||||||
|
|
||||||
if (this.options.minifyInlinedCSS) {
|
if (this.options.minifyInlinedCSS) {
|
||||||
cssContent = cssContent
|
cssContent = cssContent
|
||||||
|
// Comments.
|
||||||
|
.replace(/\/\*([\s\S]*?)\*\//g, '')
|
||||||
// New lines.
|
// New lines.
|
||||||
.replace(/\n/g, '')
|
.replace(/\n/g, '')
|
||||||
// Comments and new lines.
|
|
||||||
.replace(/\/\*\s.+\s\*\//g, '')
|
|
||||||
// Safe spaces.
|
// Safe spaces.
|
||||||
.replace(/\s?[\{\:\;]\s+/g, s => s.trim());
|
.replace(/\s?[\{\:\;]\s+/g, s => s.trim());
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,27 @@ describe('InlineFontsProcessor', () => {
|
|||||||
expect(html).toContain(`font-family: 'Material Icons'`);
|
expect(html).toContain(`font-family: 'Material Icons'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should inline multiple fonts from a single request with minification enabled', async () => {
|
||||||
|
const inlineFontsProcessor = new InlineFontsProcessor({
|
||||||
|
minifyInlinedCSS: true,
|
||||||
|
WOFFSupportNeeded: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const html = await inlineFontsProcessor.process(`
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500%7CGoogle+Sans:400,500%7CRoboto+Mono:400,500%7CMaterial+Icons&display=swap" rel="stylesheet">
|
||||||
|
<link href="theme.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
</html>`);
|
||||||
|
|
||||||
|
expect(html).toContain(`'Google Sans'`);
|
||||||
|
expect(html).toContain(`'Roboto'`);
|
||||||
|
expect(html).toContain(`'Roboto Mono'`);
|
||||||
|
expect(html).toContain(`'Material Icons'`);
|
||||||
|
});
|
||||||
|
|
||||||
it('works with http protocol', async () => {
|
it('works with http protocol', async () => {
|
||||||
const inlineFontsProcessor = new InlineFontsProcessor({
|
const inlineFontsProcessor = new InlineFontsProcessor({
|
||||||
WOFFSupportNeeded: false,
|
WOFFSupportNeeded: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user