Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 90d6939

Browse files
committed
fix(@nguniversal/common): correctly handle multiple lazy CSS files
This commit fixes an issue with the regexp that caused incorrect output. Closes #3128 (cherry picked from commit b603f35)
1 parent 07a29f4 commit 90d6939

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

integration/express-engine-ivy/angular.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@
4848
"tsConfig": "tsconfig.app.json",
4949
"aot": true,
5050
"assets": ["src/favicon.ico", "src/assets"],
51-
"styles": ["src/styles.css"],
51+
"styles": [
52+
"src/styles.css",
53+
{
54+
"input": "src/styles-extra.css",
55+
"inject": true,
56+
"bundleName": "extra"
57+
}
58+
],
5259
"scripts": []
5360
},
5461
"configurations": {

integration/express-engine-ivy/e2e/src/app.e2e-spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,12 @@ describe('Hello world E2E Tests', () => {
6161
await browser.driver.get(browser.baseUrl);
6262

6363
// Test the contents from the server.
64-
const styleTag = browser.driver.findElement(by.css('link[rel="stylesheet"]'));
65-
expect(styleTag.getAttribute('media')).toMatch('all');
64+
const linkTags = await browser.driver.findElements(by.css('link[rel="stylesheet"]'));
65+
expect(linkTags.length).toBe(2);
66+
67+
for (const linkTag of linkTags) {
68+
expect(linkTag.getAttribute('media')).toMatch('all');
69+
}
6670

6771
// Make sure there were no client side errors.
6872
verifyNoBrowserErrors();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* You can add global styles to this file, and also import other style files */
2+
.foo {
3+
background-color: blue;
4+
}

modules/common/engine/src/engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class CommonEngine {
102102
document: inlineCriticalCss
103103
? // Workaround for https://github.com/GoogleChromeLabs/critters/issues/64
104104
doc.replace(
105-
/ media="print" onload="this\.media='.+'"(?: ngCspMedia=".+")?><noscript><link .+?><\/noscript>/g,
105+
/ media="print" onload="this\.media='.+?'"(?: ngCspMedia=".+")?><noscript><link .+?><\/noscript>/g,
106106
'>',
107107
)
108108
: doc,

0 commit comments

Comments
 (0)