Support Webpack 5, drop copypasted webpack-virtual-modules#151
Support Webpack 5, drop copypasted webpack-virtual-modules#151benmccann merged 1 commit intosveltejs:masterfrom
Conversation
|
Just tested this and it works great, but only when |
|
|
I'll make one slight change. |
Fixes sveltejs#139, Fixes sveltejs#131, Fixes sveltejs#126 Co-authored-by: Smittyvb <me@smitop.com>
|
I've used |
|
@non25 , can you please share your webpack config regarding this? Here is my webpack config Throws the following error: |
It looks like you are still using published Install # yarn 2
yarn add -D svelte-loader@sveltejs/svelte-loader
# npm
npm install -D sveltejs/svelte-loaderAlso you can look at https://github.com/non25/webpack-svelte-tests for an inspiration. |
|
@non25 , thank you for your quick response, I will test it now! |
|
I used the sveltejs/svelte-loader and the issues I was having went away. However, I am using Github Actions as a CI tool and it gives me "private repositor" build error message. I guess I am waiting for this to publish to NPM then, or is there a way to use this sort of repository from Github Actions? In the meantime I'm using the svelte-loader-hot and that's working ok. |
|
@rwoodnz v3 with webpack 5 support is published to npm already https://www.npmjs.com/package/svelte-loader |
|
Thanks! I will give it another go |
|
That works for me - good work! Should the install instructions save to dev dependencies instead? |
Yes: |
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 Mapwhich contain pairs*.svelte.{index}.css: contentandindexto prevent key overlaps when compiling concurrently for SSR and browser.The loader saves css string to the
virtualModules Mapand 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.cssloaders chain.Every time css is read from the
virtualModules Mapit gets deleted to prevent leaks.I'm currently using this approach in
svelte-loader-hoton production.Fixes #139, Fixes #131, Fixes #126
This wouldn't be possible without @trash-and-fire