Skip to content

Support Webpack 5, drop copypasted webpack-virtual-modules #11

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

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

Support Webpack 5, drop copypasted webpack-virtual-modules #11

wants to merge 1 commit into from

Conversation

non25
Copy link

@non25 non25 commented Jan 13, 2021

It drops webpack-virtual-modules in favor of much more simple and sane setup described here: webpack/webpack#11074 (comment)

The setup works both for webpack 4 and 5. Emitted css reloads just fine on component change on both of them.

This PR changes make use of custom loader string, virtualModules Map which contain pairs *.svelte.{index}.css: content and index to prevent key overlaps when compiling concurrently for SSR and browser.

The loader saves css string to the virtualModules Map and appends an import with custom loader string, relaunching svelte-loader with cssPath parameter, which makes it output css basically from the void (without a file) and pass it further to the .css loaders chain.

Every time css is read from the virtualModules Map it gets deleted to prevent leaks.

I'm currently using this approach in svelte-loader-hot on production.

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