Add Ability to Configure Svelte-Loader Options
See original GitHub issueI love storybook, but I can’t use it with my Svelte components because I’m using a stylus preprocessor with my components and (as far as I can tell) there’s no way for me to tell storybook about my preprocessor.
What I need is a way to pass options into framework-preset-svelte.js
at line 11
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
svelte-loader - npm
A webpack loader for svelte. ... Start using svelte-loader in your project by running `npm i svelte-loader` ... Install. npm i svelte-loader ......
Read more >Working with Webpack | Svelte CLI - GitHub Pages
Some webpack options are set based on values in svelte.config.js and ... raw webpack config, with the ability to define named loader rules ......
Read more >Adding TypeScript to an existing Svelte project - LogRocket Blog
Add TypeScript to an existing Svelte project using a web application bundler like Parcel, Rollup, or webpack.
Read more >Learn Svelte
Every Svelte component instance has a small number of methods you can use to control it, in addition to any custom methods you...
Read more >How to setup custom elements with svelte + rails/webpacker
I've been trying to setup svelte custom elements with webpacker. This is loaders/svelte.js module.exports = { test: /\.svelte$/, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shilman Not at all. But AFAIK, @amwmedia’s solution is the correct way. I would have done it this way.
With my proposed changes in their current form, it should also keep working as it is. But that’s more luck than anything else; I experimented with changing this rule at a point, to make it work.
Maybe that would be nice to be able to expose some particularly interesting rules / loaders / loader options to users, to spare them the need to do this fragile lookup themselves, but that would be a feature from SB core (and it might be tricky to do it right).
What I can do is add a comment in Svelte’s framework presets to remind anyone that this signature (first level rule with a
loader
prop containing'svelte-loader'
) should be preserved or considered a breaking change.@amwmedia To be safe (well… safer), you should probably preserve existing loader options though.
(Or you can directly modify the
config
arg that your are provided, it is intended for that.)I think it’s safe to assume that
preprocess
will never be used by SB, so it’s safe to overwrite it. As long as you ensure that your custom preprocessor preserves support for raw syntaxes (i.e. CSS in your case).@amwmedia AFAIK there is no easy way to do that. However, as a workaround you can configure webpack manually by removing the rule in question, and adding a replacement that has the options you need. Or, if you’re feeling cavalier, just updating the existing rule in place. See https://storybook.js.org/docs/configurations/custom-webpack-config/#full-control-mode