-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
95 lines (94 loc) · 2.21 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
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
89
90
91
92
93
94
95
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: {
index: './packages/index',
utils: './packages/utils/index'
},
devtool: 'none',
mode: 'production',
output: {
filename: '[name].js',
path: path.resolve(__dirname, './dist'),
library: 'antd-doddle',
libraryTarget: 'umd',
sourceMapFilename: '[file].map', // string
},
/* optimization: {
sideEffects: false,
minimizer: [
new TerserPlugin({
cache: true,
parallel: true
})
]
}, */
externals: {
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
},
antd: {
commonjs: 'antd',
commonjs2: 'antd',
amd: 'antd',
},
moment: {
commonjs: 'moment',
commonjs2: 'moment',
amd: 'moment',
},
dva: {
commonjs: 'dva',
commonjs2: 'dva',
amd: 'dva',
},
'react-transition-group': {
commonjs: 'react-transition-group',
commonjs2: 'react-transition-group',
amd: 'react-transition-group',
},
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.tsx', '.ts', '.js']
},
module: {
rules: [{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader'
}, {
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}, {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000
}
}, {
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'style-loader', 'css-loader'],
}, {
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}, {
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader']
}]
},
plugins: [
new CleanWebpackPlugin(['dist']),
new MiniCssExtractPlugin({
filename: './index.css' // 文件目录会放入output.path里
}),
],
};