-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logic check only import css from enabled modules #32922
Add logic check only import css from enabled modules #32922
Conversation
Hi @mrtuvn. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Unit Tests, Functional Tests EE, Functional Tests CE, Database Compare, Integration Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Unit Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@mrtuvn, TBH this solution looks better and much simpler to me. The only concern I still have about it - it’s backward incompatible and might cause issues for some people/themes. Also, could you cover your changes with unit tests? |
issue can reproduce if you add css/less styles in theme area (app/design). You can add file like this to theme example In real world case you don't want to modify directly styles in module area I want to clarify This PR aims to solve that problem. If you disabled module and you added styles before in theme area -> So we don't want that styles (in theme) should be visible at frontend/customers |
@magento run all tests |
✔️ QA PassedIssue addressed in this PR: Classes belongs to disabled modules should not available at final css output files(styles-m.css,styles-l.css) Solution given & Expected behaviour: In this PR, “static_content_only_enabled_modules” this flag is introduced. We have to set the flag 'static_content_only_enabled_modules' => 0 or 1 and needs to check the pub\static\frontend\Magento\blank\en_US\styles-m.css file and here are three scenarios with expected output
Now in order to proceed on testing, I have tried to reproduce the issue on latest 2.4-develop Manual testing scenario: Moving it to |
@magento run Functional Tests EE,Functional Tests CE,Functional Tests B2B,WebAPI Tests |
Functional Tests EE,Functional Tests CE,Functional Tests B2B some failure are known failure and other are different on last two run on same commit. Known Failure Web Api Tests failure is known failure Hence moving it to |
@magento run all tests |
PR isn't marked as merged (probably because of the additional commit after it got accepted), but seems to be merged in this bigger merge: ada8d1d. Finally, this has been in the making since the hackathon at Magento Live 2019 in Amsterdam, thank you to everybody involved with this 🎉 🙌 I'm curious how this will perform, we've been using the alternative solution to this problem, using the following PR since 2021 on all our shops running Magento 2.4.x and haven't seen any issues with it so far. Also, the new |
78749c0
into
magento:2.4-develop
Finally it marked as merged! Thank you! |
Description (*)
This PR based on workarounds @vasilii-b for resolve this remain issue. Default magento import all css from all modules in (app/etc/config.php) no matter it was enabled or not.
See file less in var/view_preprocessed/pub/static/frontend/Vendor/theme/locale/css
For normal site with small customise module css size is not problem but imagine store have a lot of modules and each module have custom styles. Css output size will be huge and delay browser parse css
when see file styles-m.less or styles-l.less, you can see this line
It's not actually comment code. This is syntax by magento allow import external modules and widgets styles across in all modules and themes
Current exists problem
If we disabled module but we add styles inside theme -> these styles in theme also added to final output instead expect not available in final css.
Benefits/Expects
assume If module disabled so that styles listed below should not be include in output styles
disabled module is deprecated but some case if we need or know exactly problem come from some module. We can disabled it and also make sure styles come from theme of that module will not parse at final output css.
The benefits => reduce size outputs css file
Some downside/edge-cases
Case 1 (Rarely): If we add styles of disabled module to enabled module. We can't exclude it. I'm not sure in real-world we may got this case (look like it's related with manager code/quality)
Example
Magento_Review -> disabled
in theme luma theme-frontend-luma/Magento_Catalog/web/css/source/_extend.less
theme-frontend-luma/Magento_Review/web/css/custom.less <= styles in here still loaded. Only styles from files, _module.less, widget, _extend will able wipe out
Known limitations
Some variables added/defined in module less. But some other files such as (_extends.less) reference/use/call to it. One case will false if we disabled module
Solutions: Need refactor files to loose tight-coupling
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
'static_content_only_enabled_modules' => true,
Questions or comments
Contribution checklist (*)