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.

Webpack Hot Reload not working in react Storybook 6.0-rc.9

See original GitHub issue

Describe the bug After changing a story the page reloads and I get following message in the browser console

[HMR] The following modules couldn't be hot updated: (Full reload needed)
This is usually because the modules which have changed (and their parents) do not know how to hot reload themselves. See https://webpack.js.org/concepts/hot-module-replacement/ for more details.

To Reproduce

  1. Fresh install of storybook 6 react with npx sb@next init --type react
  2. Go to the button story
  3. Change something inside ‘stories/Button.stories.js’
Primary.args = {
  ...
  label: 'Button',
};

Expected behavior A hot reload without page reload

Screenshots react

System: Please paste the results of npx -p @storybook/cli@next sb info here.

Environment Info:

  System:
    OS: Linux 5.4 Pop!_OS 20.04 LTS
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 10.19.0 - /usr/bin/node
    Yarn: 1.22.4 - ~/.npm-global/bin/yarn
    npm: 6.14.4 - /usr/bin/npm
  Browsers:
    Chrome: 83.0.4103.116
    Firefox: 78.0.1
  npmPackages:
    @storybook/addon-actions: ^6.0.0-rc.9 => 6.0.0-rc.9 
    @storybook/addon-essentials: ^6.0.0-rc.9 => 6.0.0-rc.9 
    @storybook/addon-links: ^6.0.0-rc.9 => 6.0.0-rc.9 
    @storybook/react: ^6.0.0-rc.9 => 6.0.0-rc.9 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
hamanovichcommented, Sep 21, 2020

Also confirm, using 6.0.21 and MiniCssExtractPlugin loader. HMR doesn’t work.

webpackFinal: async (config, { configType }) => {
    config.module.rules.push({
        test: /\.scss$/,
        use: [
        {
            loader: MiniCssExtractPlugin.loader,
            options: {
                hmr: true,
            },
        },
        'css-loader',
        'postcss-loader',
        {
            loader: 'sass-loader',
            options: {
            implementation: require('sass'),
            sassOptions: {
                fiber: require('fibers'),
            },
            },
        },
        ],
    });
    return config;
  }

Moreover, once I run yarn storybook it throws an error: ERROR in ./src/styling/brands/XXX.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./node_modules/mini-css-extract-plugin/dist/loader.js??ref–16-0!./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/src!./node_modules/sass-loader/dist/cjs.js??ref–16-3!./src/styling/brands/XXX.scss) Module build failed (from ./node_modules/sass-loader/dist/cjs.js): SassError: expected “{”. ╷ 4 │ var cssReload = require(“/Users/XXX/node_modules/mini-css-extract-plugin/dist/hmr/hotModuleReplacement.js”)(module.id, {“hmr”:true,“reloadAll”:true,“locals”:false}); │

On the version 5.2.8 HMR works fine

0reactions
hamanovichcommented, Sep 27, 2020

@shilman can’t surely answer, I used the default config from https://webpack.js.org/plugins/mini-css-extract-plugin/#advanced-configuration-example and @storybook/preset-scss together -> HMR doesn’t work, and yarn storybook throws an error described above. Finally, I removed this preset -> and it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook webpack repeatedly rebuilding (hot reloading over ...
There is an issue on GitHub (Webpack Building Constantly) describing a similar behavior. They solved it by changing the glob of the stories ......
Read more >
Storybook does not refresh after save : r/pop_os - Reddit
I have created a Storybook and after when I change something and save it, the browser does not refresh automatically.
Read more >
Sebastien Lorber • ⚛️ ThisWeekInReact.com on Twitter ...
An integration package between React-Three-Fiber and Remix Bridges Remix context to R3f => hooks can be used in R3f scenes directly https://github.com/nickjs/ ...
Read more >
Webpack-热中间件, 热模块更换反应 ...
Webpack Hot Reload not working in react Storybook 6.0-rc.9 · 问题运行正常显示VUE-Ui 警告不能加载hot.js Hot Reload Not Working 2018 年12 月24 日sodatea 置顶 ...
Read more >
Hot Reload - npm - Socket.dev
Storybook for Vue3: Develop Vue3 Component in isolation with Hot Reloading. storybook ... Webpack hot reloading you can attach to your own server....
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