forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
57 lines (50 loc) · 1.68 KB
/
webpack.config.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
const path = require('path');
const os = require('os');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// Export a function. Accept the base config as the only param.
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
// configType has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.
/* eslint-disable-next-line */
defaultConfig.resolve = defaultConfig.resolve || {};
/* eslint-disable-next-line */
defaultConfig.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx'];
defaultConfig.plugins.push(
new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: true,
}),
);
defaultConfig.module.rules[0].use[0].options.plugins.push('@babel/plugin-syntax-dynamic-import');
defaultConfig.module.rules.push({
exclude: /node_modules/,
include: new RegExp(
`${path.resolve(__dirname, '../../superset-ui-(legacy-)*(plugin|preset)-')}.+/src`,
),
test: /\.jsx?$/,
use: defaultConfig.module.rules[0].use,
});
defaultConfig.module.rules.push({
test: /\.tsx?$/,
use: [
{ loader: 'cache-loader' },
{
loader: 'thread-loader',
options: {
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
workers: os.cpus().length - 1,
},
},
{
loader: 'ts-loader',
options: {
// transpile only in happyPack mode
// type checking is done via fork-ts-checker-webpack-plugin
happyPackMode: true,
},
},
],
});
// Return the altered config
return defaultConfig;
};