This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Extend internal rollup plugin to replace extract_css #1415
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1397
Fixes #1388
This is testing out using the code from @ajbouh's fork to handle CSS. It uses the core of his implementation, but leaves out a lot of his changes unrelated to CSS handling to make it a smaller easier to review change. Thanks for providing this @ajbouh!
The reason I like this approach is that I think it makes sense that css handling would happen in a Rollup plugin. E.g. Rollup handles calculating the file hash for us automatically which fixes the bug where it wasn't calculated correctly.
This plugin essentially produces a graph and then figures out how to create the CSS files that are necessary. It also handles dynamic imports a bit better than
master
does. It puts the CSS for dynamic imports into the file for the route that does the dynamic import.master
simply put it intomain.css
so that it was available everywhere. This could probably be further optimized, but I think it's a reasonable first implementation and an improvement over what we have todayThe plugin could almost be refactored out to be a standalone CSS code splitting Rollup plugin. However, that would probably depend on cutting a new release of rollup-plugin-svelte and requiring users to use the latest version which takes advantage of Rollup's asset handling (sveltejs/rollup-plugin-svelte#72)