dnafactory / module-critical
A module that allows to serve the critical.css generated by less, directly from the static contents.
Installs: 2 290
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:magento2-module
Requires
- php: ^7.1|^8.1
- magento/magento2-base: >=2.4.2
README
A module that handles the critical css generation from less sources.
The elephant in the room
If you want to serve critical css as less sources, of course, you can put your critical.less in your custom theme directory.
app/design/frontend/[Vendor]/[Custom-Theme]/web/css/critical.less
And then, in the static:content:deploy phase, the critical.css file will be generated and saved in the static content folder. However, even in production mode, Magento will always try to fetch that file from the source directory, so it will re-build critical.css on each request.
Solution
This module simply replaces Magento's original ViewModel that reads the critical.css content, to fetch it from the static content folder instead.
Happy Coding