Broken build Storybook 6.3.7 + Webpack 5
See original GitHub issueBroken build with latest Storybook (6.3.7) + Webpack 5
main.js
const path = require("path");
const custom = require("../webpack.config.js");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
core: {
builder: "webpack5",
},
stories: ["../src/**/*.story.tsx"],
addons: [
"@storybook/addon-toolbars",
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-viewport",
"@storybook/addon-docs",
"@storybook/addon-controls",
{
name: "@storybook/preset-typescript",
options: {
tsLoaderOptions: {
configFile: path.resolve(__dirname, "../tsconfig.json"),
},
tsDocgenLoaderOptions: {
tsconfigPath: path.resolve(__dirname, "../tsconfig.json"),
},
},
},
],
webpackFinal: async (config) => {
return {
...config,
module: {
...config.module,
rules: custom.module.rules,
},
resolve: {
...custom.resolve,
...config.resolve,
modules: [...config.resolve.modules, ...custom.resolve.modules],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}),
...config.plugins,
],
// added for Storybook 6.3.7 due to warnings or similar
output: {
chunkFormat: "array-push",
},
resolve: {
fallback: { stream: false },
},
};
},
};
main.js
worked with Storybook 6.2.8 + Webpack 4
System
Environment Info:
System:
OS: macOS Mojave 10.14.6
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 14.17.5 - /usr/local/opt/node@14/bin/node
npm: 6.14.14 - /usr/local/opt/node@14/bin/npm
Browsers:
Chrome: 92.0.4515.159
Firefox: 84.0.2
Safari: 14.1.2
npmPackages:
@storybook/addon-actions: ^6.3.7 => 6.3.7
@storybook/addon-controls: ^6.3.7 => 6.3.7
@storybook/addon-docs: ^6.3.7 => 6.3.7
@storybook/addon-links: ^6.3.7 => 6.3.7
@storybook/addon-storyshots: ^6.3.7 => 6.3.7
@storybook/addon-toolbars: ^6.3.7 => 6.3.7
@storybook/addon-viewport: ^6.3.7 => 6.3.7
@storybook/addons: ^6.3.7 => 6.3.7
@storybook/builder-webpack5: ^6.3.7 => 6.3.7
@storybook/cli: ^6.3.7 => 6.3.7
@storybook/manager-webpack5: ^6.3.7 => 6.3.7
@storybook/preset-typescript: ^3.0.0 => 3.0.0
@storybook/react: ^6.3.7 => 6.3.7
Additional context
starting with start-storybook -p 6006 -s ./public
-s
gets ignored with 6.3.7
and creates own dist folder
There are 2 issues which come up after trying to start it, sometimes it’s:
ERR! Error: For the selected environment is no default script chunk format available:
ERR! JSONP Array push can be chosen when 'document' or 'importScripts' is available.
ERR! CommonJs exports can be chosen when 'require' or node builtins are available.
ModuleNotFoundError: Module not found: Error: Can't resolve '...'
Parsed request is a module using description file: src/package.json
webpack5 build + dev build works as expected, but storybook fails unfortunately.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:7
Top Results From Across the Web
Broken build Storybook 6.3.7 + Webpack 5 #15882 - Issuehunt
Broken build Storybook 6.3.7 + Webpack 5 #15882 ... There are 2 issues which come up after trying to start it, sometimes it's:...
Read more >Storybook 6.3 - JS.ORG
Outline helps you spot misaligned or broken layouts. ... Webpack 5 is also now used to build Storybook's manager UI.
Read more >@storybook/builder-webpack5 | Yarn - Package Manager
Builder implemented with webpack5 and webpack5 -compatible loaders/plugins/config, used by @storybook/core-server to build the preview iframe.
Read more >storybook/addon-docs - npm
Document component usage and properties in Markdown. Latest version: 6.5.15, last published: 5 days ago. Start using @storybook/addon-docs ...
Read more >Storybook error when using Webpack5 with Next.JS app + ...
x.x is not installed, just install with npm i -D webpack@^5.x.x.. Share.
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 Free
Top 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
This seems related to the
target
option: https://webpack.js.org/configuration/target/It defaults to
browserslist
, my browserslist config looks like this:If I remove
maintained node versions
then the error goes away.Okay I figured out how to fix the build for my setup, my
.storybook/main.ts
now looks like this:The trickiest part was to find out how to fix the manager build, as
managerWebpack
is not/under documented.