-
Notifications
You must be signed in to change notification settings - Fork 13.9k
/
main.js
73 lines (64 loc) · 1.86 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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`,
);
module.exports = {
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;
},
};