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.

Migration to Storybook 4 issue with webpack config

See original GitHub issue

Hi Team,

During migration the storybook to new version 4.0.7, there is an issue in starting the storybook. Webpack is freaking out. The application is based on Create-React-App 1 and storybook has an extended webpack.config.js. There are two issues:

  1. Failed to load presets
  2. Cannot read property ‘rules’ of undefined (During the loading custom webpack config task)

The webpack config looks like:

const path = require("path")
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = (baseConfig, env, config) => {
  baseConfig.module.rules.push({
    test: /\.css$/,
    loaders: [
      'style-loader',
      'css-loader'
    ],
    include: path.resolve(__dirname, "../")
  });
  config.module.rules.push({
    test: /\.tsx?$/,
    loader: [
      'thread-loader',
      'ts-loader?happyPackMode=true',
      'react-docgen-typescript-loader'
    ]
  }, {
    test: /\.md$/,
    loader: [
      'thread-loader',
      'markdown-loader'
    ]
  })
  config.plugins.push(new ForkTsCheckerWebpackPlugin({
    checkSyntacticErrors: true,
    watch: path.resolve(__dirname, "../stories"),
    workers: ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
  }))
  config.resolve.extensions.push(".ts", ".tsx")
  return config;
}

Waiting for some pointers from your side in order to rectify the problem.

Thanks in advance Amit

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
andremwcommented, Mar 28, 2019

Same problem here. @amittkSharma have you found a solution?

EDIT: Actually, I managed to make it work. I simply changed .storybook/webpack.config.js from

module.exports = (baseConfig, env, config) => { to module.exports = ({ config, mode }) => {

I could even change the npm script back to "storybook": "start-storybook -p 9009 -s public",

1reaction
amittkSharmacommented, Dec 11, 2018

@igor-dv: Here is the basic repo structure, please take a look at it. In my system, I am not able to reproduce the above error as there were some updates in the past but feel free to check it.

Thanks Amit

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook 4 Migration Guide
Upgrading the Storybook package; Dealing with Webpack 4 / Babel 7 issues if you have them; Dealing with addons and minor breaking changes....
Read more >
Storybook Webpack Migration - Nx
Migrating · 1. adjust the main.js file · 2. Move any custom webpack configuration to webpackFinal · 3. Remove the root-level .storybook/webpack.config.js file...
Read more >
Migrating to Webpack 5 at smallcase - Medium
Borrow from the main webpack config in custom storybook webpack config ... There were issues which became blockers for storybook6 migration ...
Read more >
Migrating Storybook to 6.4 err: webpack < 5 used to include ...
Migrating Storybook to 6.4 err: webpack < 5 used to include polyfills ... Verify if you need this module and configure a polyfill...
Read more >
@storybook/builder-vite - npm
Getting started with Vite and Storybook (on a new project); Migration from webpack / CRA; Customize Vite config; Svelte Customization ...
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