-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
64 lines (62 loc) · 1.69 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
const webpack = require('webpack');
var es3ifyPlugin = require('es3ify-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
// multiple extract instances
var extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
//let extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
module.exports = {
entry: ["babel-polyfill", "./entry.js"],
output: {
path: __dirname+'/raw/build', //输出文件夹
publicPath: '/build',
filename: "[name].bundle.js" //最终打包生成的文件名
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.css$/,
loader: extractCSS.extract(['css'])
}
],
// rules: [{
// test: /\.js$/,
// enforce: 'post', // post-loader处理
// loader: 'es3ify-loader'
// }
// ]
},
plugins: [
new es3ifyPlugin(),
//new webpack.optimize.UglifyJsPlugin(), // 打包时 -p
new webpack.optimize.UglifyJsPlugin({
compress: {
properties: false,
warnings: false
},
output: {
beautify: true,
quote_keys: true
},
mangle: {
screw_ie8: false
},
sourceMap: false
}),
new webpack.optimize.CommonsChunkPlugin({
name:'common', // 注意不要.js后缀
//chunks:['react','react-dom'], // 会生成react.js,react-dom.js
minChunks: 4
}),
extractCSS,// css抽取
new HtmlWebpackPlugin({ //根据模板插入css/js等生成最终HTML
filename: '../index.html', //生成的html存放路径,相对于 outputPath
template: './index.html' //html模板路径
})
]
};