-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(*): add css scoping to each block #703
Conversation
Nice direction where this is going. @fulopdaniel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I noticed that the css build now is smaller and I don't get why thats the case as it should be bigger, are we missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, fat finger approved it.
@hochreutenerl We could read the manifest.json, but that does not automatically solve the issue for external blocks. They will need to configure their postcss.config.js themselves either way, and then also add that class to their block. @ragi96 I will look into the point with the css size. One potential reason why the bundle could be smaller is that I removed the tailwind important part, so that is no longer part of the bundle. Update: The CSS is has the same amount of lines with and without the plugin. The tailwind 'important' approach duplicated some rules, that's why the previous bundle was bigger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@fulopdaniel I think we can also adjust our templates - not all of them use postcss though - and add a matching class to wrapping div. |
@hochreutenerl then we probably should release the plugin properly so we don't have to copy paste the code |
Created a PostCSS Plugin that prepends every css rule in the generated style.css with an extra selector, essentially scoping the whole css file to the specific block.
becomes
Previously we relied on Tailwind's
important
scoping approach, but that does not scope css rules that were imported to the package (e.g. @frontify/guideline-blocks-settings/dist/style.css)To test:
pnpm run deploy --dryRun
inside any package