Page related Stylesheets #3407
Replies: 3 comments 5 replies
-
Hi @memoworker, thank you for your proposal. 👍 In general I think it's a good idea to introduce more purpose specific CSS to avoid unused CSS. I have one concern regarding the division into routes/pages like "category", "detail" etc. Because of the CMS elements we don't really know what exactly will be on a page. Someone could add additional elements to the "category/listing" for example. With the "Commerce" elements I am able to have almost the entire "detail" styling in the category listing page. If we divide the CSS on route level like this, I think we would have to add all CSS which COULD be on a dynamic page in the "all.scss" entry point. Maybe it could be an approach to let the CMS elements bring their CSS. Don't get me wrong, doing it like this could still be a big improvement because things like "account" could have their own CSS and are not effected by the CMS. Because of the current big CSS we have written a new ADR recently which should help us to get rid of CSS which is not needed. If we use the Bootstrap framework more appropriately and remove unneeded CSS, I think there is a lot of potential to reduce the CSS globally. |
Beta Was this translation helpful? Give feedback.
-
I really like 🤩 this idea in general. And for sure it is more complicated than it looks like. 🙈 Here are some thoughts ☁️ about the proposal: We define in a theme some new SCSS entry points that should affect how the core is building the CSS. I got the point and I guess this should be reflected in new SCSS files inside the core ... but then you will break up the 7 - 1 pattern ... and then the core will not have one And this is just the start of the rabbit hole: What about Plugins? How can Plugins then add their SCSS to a specific page? Sure we can define a structure with folders and then the core collecting the files the same way we do it for all.css but in specific folders. The downside of this would be also longer build times and more chances to run in a timeout because the PHP SCSS compiler can crash more often. [This is also another story to improve the CSS compiling, smaller chunks or in a perfect world get rid of it.] To try the new approach we could set a new What happens with Plugins that do not adapt to the new structure? So the style is lost until they adapt or should there be something like I would also love to see some I know a lot of thoughts but I just want to make sure that everyone is aware that this is not a simple topic to integrate into an existing platform. Happy to hear your feedback about this. Thx. 🤝 |
Beta Was this translation helpful? Give feedback.
-
Here is a Link to a POC that uses Vite for Shopware and tries to split the CSS (check the Readme). |
Beta Was this translation helpful? Give feedback.
-
The all.css stylesheet currently might have 200kb (400'000 Lines) of styles after installation of a few plugins and a theme.
Most of which are not needed on the current page.
Therefore it would be nice as a plugin / theme developer to have the ability to define for which type of page your style is relevant.
Afterwards only the relevant styles will be loaded by the page.
As example a theme.json could be adapted as follows to allow the changes:
There should be the following types:
The result should be a cacheable file for each of the different combinations of types.
For example:
Beta Was this translation helpful? Give feedback.
All reactions