-
Notifications
You must be signed in to change notification settings - Fork 71
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
Support Webpack 5, drop copypasted webpack-virtual-modules #151
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-loader Also 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 Map
which contain pairs*.svelte.{index}.css: content
andindex
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.Fixes #139, Fixes #131, Fixes #126
This wouldn't be possible without @trash-and-fire