question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New custom webpack customization hook doesn't act the same as old version

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ndelangencommented, Jan 13, 2020

@liorgreenb please change the webpack property to webpackFinal can you report if it works correctly then?

2reactions
chris-pearcecommented, Jan 14, 2020

I’m experiencing this issue with both webpack and webpackFinal property names.

Read more comments on GitHub >

github_iconTop Results From Across the Web

my bundle doesn't update, always shows old version of site
Webpack doesn't update my bundle and I always get same old version of my website when use npm run build . My directory:...
Read more >
Webpack 5 release (2020-10-10)
So today (2020-10-10) webpack 5.0.0 is released, but this doesn't mean it's done, bugfree or even feature-complete. As with webpack 4 we ...
Read more >
rollup.js
It uses the new standardized format for code modules included in the ES6 revision of JavaScript, instead of previous idiosyncratic solutions such as...
Read more >
Documentation | U.S. Web Design System (USWDS)
All users will have access to the same critical information and basic experience ... to install the design system and update it as...
Read more >
3 Common Tasks — The Yocto Project ® 4.1.999 documentation
This chapter describes fundamental procedures such as creating layers, adding new software packages, extending or customizing images, porting work to new ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found