-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.pro.js
More file actions
70 lines (69 loc) · 1.76 KB
/
webpack.pro.js
File metadata and controls
70 lines (69 loc) · 1.76 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
/**
* Created by easterCat on 2017/10/30.
*/
const path = require("path");
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = merge(common, {
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract(["style-loader", "css-loader"])
},
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: "css-loader"
},
{
loader: "less-loader"
}
]
})
}
]
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
new ExtractTextPlugin({
filename: "app.css",
allChunks: true // don't contain embedded styles
}),
//加入js压缩的实例
new UglifyJsPlugin({
mangle: {
mangle: false
},
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: false,
if_return: true,
join_vars: true,
drop_console: false,
warnings: false
}
}),
new HtmlWebpackPlugin({
title: "xxxx",
filename: path.resolve(__dirname, "dist/index.html"), // 生成的html存放路径
template: path.resolve(__dirname, "src/index.html"), // html模板路径,
minify: false
}),
new CleanWebpackPlugin(["dist", "dist.zip", "dist.rar"])
]
});