This repository was archived by the owner on Dec 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
88 lines (77 loc) · 1.63 KB
/
Copy pathwebpack.config.js
File metadata and controls
88 lines (77 loc) · 1.63 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const path = require('path');
const webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const TerserPlugin = require('terser-webpack-plugin');
const env = process.env.NODE_ENV;
const config = {
devtool: 'source-map',
entry: './src/index.ts',
output: {
filename: 'RechartsToolkit.js',
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
include: [
path.resolve(__dirname, 'src'),
],
loader: 'babel-loader',
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
include: [
path.resolve(__dirname, 'src'),
],
loader: 'ts-loader',
}
],
},
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
'recharts': {
root: 'Recharts',
commonjs2: 'recharts',
commonjs: 'recharts',
amd: 'recharts',
},
'd3-scale': {
root: 'd3-scale',
commonjs2: 'd3-scale',
commonjs: 'd3-scale',
amd: 'd3-scale',
}
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env),
__DEV__: false,
__DEVTOOLS__: false,
}),
],
};
// if (env === 'analyse') {
config.plugins.push(
new BundleAnalyzerPlugin()
);
// }
if (env === 'production') {
config.mode = 'production';
config.optimization = {
minimize: true,
minimizer: [
new TerserPlugin(),
],
};
}
module.exports = config;