31468a37
Yang Xiaoxiao
source
|
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
|
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
const PATHS = {
react: path.join(__dirname, 'node_modules/react/dist/react.min.js'),
app: path.join(__dirname, 'src'),
build: path.join(__dirname, './dist')
};
module.exports = {
context: path.join(__dirname),
devtool: false,
entry: "./src/js/root.js",
// devtool: false,
// sourceMap :false,
// devServer: {
// inline: false,
// historyApiFallback: false,
// port: 3000
// },
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015','stage-1'],
plugins: ['react-html-attrs'], //添加组件的插件配置
}
},
//下面是使用 ant-design 的配置文件
{ test: /\.css$/, loader: 'style-loader!css-loader' ,
options: {
modules: true,
}
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: "file-loader?name=/images/[name].[ext]",
}
]
},
output: {
path: __dirname,
filename: "./src/bundle.js"
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(), //删除类似的重复代码
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }), //最小化一切
new webpack.optimize.AggressiveMergingPlugin(),//合并块
],
};
|