New custom webpack customization hook doesn't act the same as old version
See original GitHub issueDescribe the bug
I tried to migrate my storybook to work with the new main.js
configuration, part of it was moving the webpack.config.js
be the webpack
property in the main.js
file.
Overall, i tried to change the configuration with .svg
files, which storybook uses file-loader
and I want to use @svgr/webpack
or svg-inline-loader
.
Previously, i changed the loader rule as mentioned here: https://github.com/storybookjs/storybook/issues/6188#issuecomment-570910186
Using the ‘webpack’ function in main js: The inputed config i got did NOT have the file loader module rule (seems to be added after customization), so it didn’t work.
Using the old separate webpack.config.js
:
Seems to receive the full storybook webpack config, to it did work.
To Reproduce
Try to change the configuration for svg
files using
module.exports = {
stories: ["**/*.stories.*"],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
],
webpack: async config => {
const fileLoaderRule = config.module.rules.find(rule => rule.test.test('.svg'));
fileLoaderRule.exclude = /\.svg$/;
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack", "url-loader"],
});
return config;
};
};
Now importing a .svg
file should be imported as a react component (or a string if using svg-inline-loader
instead of using file-loader
and reciving a url.
Expected behavior
I expected to receive the final storybook webpack configuration to allow full modification, making the svg
loader changeable.
System:
Environment Info:
System:
OS: macOS Mojave 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Binaries:
Node: 8.10.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.13.2 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.117
Firefox: 68.0.1
Safari: 12.1.1
npmPackages:
@storybook/addon-actions: 5.3.0 => 5.3.0
@storybook/addon-knobs: 5.2.8 => 5.2.8
@storybook/addon-links: 5.3.0 => 5.3.0
@storybook/addons: 5.3.0 => 5.3.0
@storybook/react: 5.3.0 => 5.3.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (2 by maintainers)
Top GitHub Comments
@liorgreenb please change the
webpack
property towebpackFinal
can you report if it works correctly then?I’m experiencing this issue with both
webpack
andwebpackFinal
property names.