-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
68 lines (64 loc) · 1.96 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
const {
CleanWebpackPlugin
} = require("clean-webpack-plugin")
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const webpack = require('webpack')
module.exports = {
entry: "./src/index.js",
output: {
filename: "index.js",
path: __dirname + "/dist"
},
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
mode: 'development',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".js", ".json"]
},
externals: {
immutable: 'commonjs2 immutable',
isobject: 'commonjs2 isobject',
'kind-of': 'commonjs2 kind-of',
'tree-snap-shot':'commonjs2 tree-snap-shot'
},
module: {
rules: [
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ["@babel/preset-env"] // 也可以写成presets:['babel-preset-env']
}
},
exclude: '/node_modules/'
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new CleanWebpackPlugin(),
new UglifyJsPlugin(),
// keep module.id stable when vender modules does not change
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
],
optimization: {
chunkIds: "size",
// method of generating ids for chunks
moduleIds: "size",
// method of generating ids for modules
mangleExports: "size",
// rename export names to shorter names
minimize: true,
},
};