-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
52 lines (51 loc) · 1.47 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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'index': __dirname + '/src/sokudo/js/index'
},
output: {
path: __dirname + "/docs",
filename: '[name].js'
},
devtool: 'source-map',
devServer: {
contentBase: "./public",
port: 4444, // 监听端口号
inline: true, // 实时刷新
historyApiFallback: true
// 在开发单页应用时非常有用,它依赖于HTML5 history API,如果设置为true,所有的跳转将指向index.html
},
resolve: {
extensions: ['.js', '.less', '.html']
},
module: {
rules: [{
test: /\.js$/,
use: {
loader: 'babel-loader',
},
exclude: /node_moudles/
}, {
test: /\.(css|less)$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader",
}, {
loader: "less-loader"
}]
}]
},
plugins: [
new webpack.BannerPlugin('版权所有,翻版必究'), // 在打包后的代码中添加注释
// 简历
new HtmlWebpackPlugin({
template: __dirname + '/src/sokudo/index.html'
}),
new HtmlWebpackPlugin({
template: __dirname + '/src/resume/index.html'
}),
new webpack.optimize.UglifyJsPlugin(), //压缩js代码
]
}