Skip to content

Commit

Permalink
Update storybook builder to webpack 5
Browse files Browse the repository at this point in the history
  • Loading branch information
scinos committed Sep 16, 2021
1 parent 56e1ef2 commit effd0a7
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 66 deletions.
10 changes: 9 additions & 1 deletion bin/storybook-default-config.js
Expand Up @@ -5,8 +5,15 @@ const { dirname } = require( 'path' );
// of the given module.
const findModule = ( module ) => dirname( require.resolve( module + '/package.json' ) );

module.exports = function storybookDefaultConfig( { stories, webpackAliases = {} } = {} ) {
module.exports = function storybookDefaultConfig( {
stories,
plugins = [],
webpackAliases = {},
} = {} ) {
return {
core: {
builder: 'webpack5',
},
stories: stories && stories.length ? stories : [ '../src/**/*.stories.{js,jsx,ts,tsx}' ],
addons: [ '@storybook/addon-actions', '@storybook/preset-scss' ],
typescript: {
Expand Down Expand Up @@ -39,6 +46,7 @@ module.exports = function storybookDefaultConfig( { stories, webpackAliases = {}
...webpackAliases,
};
config.resolve.mainFields = [ 'browser', 'calypso:src', 'module', 'main' ];
config.plugins.push( ...plugins );
return config;
},
};
Expand Down
10 changes: 9 additions & 1 deletion packages/search/.storybook/main.js
@@ -1,2 +1,10 @@
const storybookDefaultConfig = require( '../../../bin/storybook-default-config' );
module.exports = storybookDefaultConfig();
const webpack = require('webpack');

module.exports = storybookDefaultConfig({
plugins: [
new webpack.ProvidePlugin( {
process: 'process/browser.js',
} ),
]
});
2 changes: 2 additions & 0 deletions packages/search/package.json
Expand Up @@ -46,6 +46,8 @@
"@babel/core": "^7.14.8",
"@babel/preset-env": "^7.14.8",
"@storybook/addon-actions": "^6.3.8",
"@storybook/builder-webpack5": "^6.3.8",
"@storybook/manager-webpack5": "^6.3.8",
"@storybook/preset-scss": "^1.0.3",
"@testing-library/dom": "^8.1.0",
"@testing-library/react": "^12.0.0",
Expand Down

0 comments on commit effd0a7

Please sign in to comment.