Skip to content

Commit

Permalink
chore: Update Storybook bundler to webpack 5 (#56305)
Browse files Browse the repository at this point in the history
* Update storybook builder to webpack 5

* Refactor storybook CI to avoid using NODE_ENV
  • Loading branch information
scinos committed Sep 16, 2021
1 parent efb7d97 commit 9f85848
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 78 deletions.
16 changes: 4 additions & 12 deletions .teamcity/_self/projects/WebApp.kt
Expand Up @@ -264,21 +264,13 @@ object RunAllUnitTests : BuildType({
"""
}
bashNodeScript {
name = "Build components storybook"
name = "Run storybook tests"
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
scriptContent = """
export NODE_ENV="production"
set -x
yarn components:storybook:start --ci --smoke-test
"""
}
bashNodeScript {
name = "Build search storybook"
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
scriptContent = """
export NODE_ENV="production"
yarn search:storybook:start --ci --smoke-test
yarn composite-checkout:storybook:start --ci --smoke-test
"""
}
}
Expand Down Expand Up @@ -807,4 +799,4 @@ object PreReleaseE2ETests : BuildType({
failureConditions {
executionTimeoutMin = 20
}
})
})
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 9f85848

Please sign in to comment.