-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(storybok): upgrade to webpack5 in storybook of plugins (#17909)
* refactor: use webpack5 in plugins storybook * remove ./src from packages.json
- Loading branch information
1 parent
4479fc9
commit 97a78d3
Showing
14 changed files
with
84 additions
and
137 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 17 additions & 62 deletions
79
superset-frontend/packages/superset-ui-demo/.storybook/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,28 @@ | ||
const path = require('path'); | ||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
const { lstatSync, readdirSync } = require('fs'); | ||
|
||
// find @superset-ui packages | ||
const basePath = path.resolve(__dirname, '../../../node_modules/@superset-ui'); | ||
const packages = readdirSync(basePath).filter(name => { | ||
const stat = lstatSync(path.join(basePath, name)); | ||
return stat.isSymbolicLink(); | ||
}); | ||
|
||
const PLUGIN_PACKAGES_PATH_REGEXP = new RegExp( | ||
`${path.resolve( | ||
__dirname, | ||
'../../../plugins/(legacy-)*(plugin|preset)-', | ||
)}.+/src`, | ||
); | ||
const customConfig = require('../../../webpack.config.js'); | ||
|
||
module.exports = { | ||
core: { | ||
builder: 'webpack5', | ||
}, | ||
addons: [ | ||
'@storybook/addon-knobs', | ||
'storybook-addon-jsx', | ||
'@storybook/addon-actions', | ||
'@storybook/addon-links', | ||
], | ||
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 | ||
config.module.rules.push({ | ||
include: PLUGIN_PACKAGES_PATH_REGEXP, | ||
exclude: /node_modules/, | ||
test: /\.jsx?$/, | ||
use: config.module.rules[0].use, | ||
}); | ||
|
||
config.module.rules.push({ | ||
test: /\.tsx?$/, | ||
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 | ||
Object.assign(config.resolve.alias, { | ||
...packages.reduce( | ||
(acc, name) => ({ | ||
...acc, | ||
[`@superset-ui/${name}$`]: path.join(basePath, name, 'src'), | ||
}), | ||
{}, | ||
), | ||
}); | ||
|
||
config.devtool = 'eval-cheap-module-source-map'; | ||
config.devServer = { | ||
...config.devServer, | ||
stats: 'minimal', | ||
}; | ||
|
||
return config; | ||
webpackFinal: config => ({ | ||
...config, | ||
module: { | ||
...config.module, | ||
rules: customConfig.module.rules, | ||
}, | ||
resolve: { | ||
...config.resolve, | ||
...customConfig.resolve, | ||
}, | ||
}), | ||
typescript: { | ||
reactDocgen: 'none', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters