build: optimize storybook config (#600)

- Output minimal webpack stats only when in development mode
- Separate type checking and build, so failed typing does not block
  `yarn sb` watch rebuild
- Rearrange addon loading order so knobs can appear as the first tab
This commit is contained in:
Jesse Yang 2020-06-15 09:59:21 -07:00 committed by Yongjie Zhao
parent 84672b99b4
commit e5feefe035

View File

@ -1,4 +1,5 @@
const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const { lstatSync, readdirSync } = require('fs');
// find @superset-ui packages
@ -15,16 +16,13 @@ const PLUGIN_PACKAGES_PATH_REGEXP = new RegExp(
module.exports = {
addons: [
'@storybook/preset-typescript',
'@storybook/addon-actions/register',
'@storybook/addon-knobs/register',
'storybook-addon-jsx/register',
'@storybook/addon-actions/register',
'@storybook/addon-links/register',
],
stories: [
'../storybook/stories/**/*Stories.[tj]sx',
],
stories: ['../storybook/stories/**/*Stories.[tj]sx'],
webpackFinal: config => {
// Make sure babel is applied to the package src
// These are excluded by the default rule
// because they reside in node_modules
@ -40,10 +38,15 @@ module.exports = {
use: [
{
loader: require.resolve('ts-loader'),
options: {
transpileOnly: true,
},
},
],
});
config.plugins.unshift(new ForkTsCheckerWebpackPlugin());
config.resolve.extensions.push('.ts', '.tsx');
// Let webpack know where to find the source code
@ -57,7 +60,11 @@ module.exports = {
),
});
config.stats = 'errors-warnings';
config.devtool = 'eval-cheap-module-source-map';
config.devServer = {
...config.devServer,
stats: 'minimal',
};
return config;
},