Skip to content
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 keep-css-imports plugin #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add keep-css-imports plugin #125

wants to merge 1 commit into from

Conversation

SLTKA
Copy link

@SLTKA SLTKA commented Apr 17, 2024

Awesome Contribution Checklist:

  • I have read, and re-read the Contributing Guidelines
  • I have searched to ensure the suggested item doesn't exist on this list
  • This PR contains only one item (and follows the guide to remove trailing spaces on sucrase description, I can remove line break instead)

Please Provide a Link A Repository for Your Addition

https://github.com/SLTKA/rollup-plugin-keep-css-imports

Please Describe Your Addition

keep-css-imports allows to maintain the original structure of style imports (CSS, SCSS, or SASS) without altering them during the bundling process. It will be helpful for building a components library and want to keep all CSS module imports untouched so consumer decide how to bundle or tree shake them.

If it meets SASS or SCSS import it will compile it and output as a single imported CSS file in dist. Plugin can be configured to maintain component folder structure or produce flattened output.

Rollup and Webpack based consumers can easily ignore the produced CSS file if component imported them was not used.

This is an alternative to CSS-in-JS plugins and allow consumers to produce separate Server Side Rendered HTML and CSS which loads much faster than dynamic (forces to wait for JS to run to inject CSS) or inline (doesn't allow separate CSS files caching in browsers) CSS-in-JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant