inlineCriticalCss not working with SSR.
See original GitHub issue🐞 Bug report
What modules are related to this issue?
- aspnetcore-engine
- builders
- common
- express-engine
- hapi-engine
Is this a regression?
not sure
Description
With inlineCriticalCss set to true, the below error occurs. I found that in ‘embedLinkedStylesheet’ the href value is undefined when it tries to process this element;
<link rel="stylesheet" href="styles.162799855ab4c03c113b.css">
Since the file path isn’t a url the ‘href’ value is undefined. Not sure if this is a change that needs to happen in Critters or in Angular. I did find this similar issue in a different project: https://github.com/GoogleChromeLabs/critters/issues/71
🔥 Exception or Error
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:124:11)
at Object.resolve (path.js:139:9)
at CrittersExtended.getCssAsset (C:\Users\X\repos\X\dist\Project\server\main.js:137185:31)
at CrittersExtended.embedLinkedStylesheet (C:\Users\X\repos\X\dist\Project\server\main.js:137265:37)
at C:\Users\X\repos\X\dist\Project\server\main.js:137114:79
at Array.map (<anonymous>)
at C:\Users\X\repos\X\dist\Project\server\main.js:137114:61
at CrittersExtended.process (C:\Users\X\repos\X\dist\Project\server\main.js:137116:8)
at InlineCriticalCssProcessor.<anonymous> (C:\Users\X\repos\X\dist\Project\server\main.js:137609:44)
at Generator.next (<anonymous>)
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 12.0.0
Node: 14.15.1
Package Manager: npm 6.14.8
OS: win32 x64
Angular: 12.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1200.0
@angular-devkit/build-angular 12.0.0
@angular-devkit/core 12.0.0
@angular-devkit/schematics 12.0.0
@nguniversal/builders 12.0.0
@nguniversal/common 12.0.0
@nguniversal/express-engine 12.0.0
@schematics/angular 12.0.0
rxjs 6.6.2
typescript 4.2.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Critical inline css is not working · Issue #22083 · vercel/next.js
I've went over both Next and Tailwindcss documentation and set everything up as instructed but the styles still do not get injected and...
Read more >Dynamically Inlining Critical CSS with Server-side JavaScript
To solve this problem, PageSpeed recommends adding inline CSS to the HTML document. This doesn't mean we want to embed the entire stylesheet ......
Read more >How do I collect critical-css for chunks of ... - Stack Overflow
Problem #1 - Critical CSS extraction My SSR setup is based on renderToNodeStream not renderToString so I cant compare html with css so...
Read more >Addy Osmani on Twitter: "Inlining critical CSS can improve ...
Such a good news!!! Yes, sure, the problem is whether to inline CSS or not, and has nothing to do with the megabytes...
Read more >Angular Security - Disable Inline Critical CSS - 0xdbe
This problem is not new since inline CSS is used by Angular for Component Style. So, inlining critical CSS should not further affect...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@alan-agius4 I believe I have figured out the issue. I have a custom caching layer in the rendering process, mostly to save cached outputs of already rendered pages for a specified time.
I realized that I wasn’t passing through every renderOption through as I should. The main one I forgot here was ‘publicPath’ which caused different behavior here potentially: https://github.com/angular/universal/blob/master/modules/common/engine/src/engine.ts#L68
After passing through the ‘publicPath’ RenderOption, I was able to get the proper async CSS and no errors when rending with ‘inlineCriticalCss’ set to true. Looks as this was an issue in my custom implantation, not an issue with the new inlineCriticalCss functionality.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.