Skip to content

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