forked from kinddde/js-export-excel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
73 lines (66 loc) · 1.98 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
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: ['./example/main.js']
},
output: {
path: path.resolve(__dirname, './test'),
publicPath: '/test/',
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: [
['es2015']
]
}
}
]
},
devServer: {
historyApiFallback: true,
contentBase: path.join(__dirname, "/test"),
compress: false,
port: 9000
},
performance: {
hints: false
},
// devtool: '#eval-source-map',
plugins: [
new HtmlWebpackPlugin({ //根据模板插入css/js等生成最终HTML
//favicon:'./src/img/favicon.ico', //favicon路径
filename: 'index.html', //生成的html存放路径,相对于 path
template: './example/index.html', //html模板路径
inject: true, //允许插件修改哪些内容,包括head与body
hash: true, //为静态资源生成hash值
minify: { //压缩HTML文件
removeComments: false, //移除HTML中的注释
collapseWhitespace: false //删除空白符与换行符
}
})
]
}
if (process.env && process.env.NODE_ENV === 'production') {
// module.exports.devtool = '#source-map'
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false,
drop_debugger: true,
drop_console: true
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}