-
Notifications
You must be signed in to change notification settings - Fork 68
/
webpack.config.js
39 lines (37 loc) · 1.1 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
let path = require('path');
let webpack = require('webpack');
// 插件都是一个类,所以我们命名的时候尽量用大写开头
let HtmlWebpackPlugin = require('html-webpack-plugin');
let CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
filename: "bundle.[hash:4].js",
path: path.resolve("dist")
},
module: {
rules: [
{
test: /\.jsx$/,
use: 'bable-loader',
include: /src/, // 只转化src目录下的js
exclude: /node_modules/, // 排除掉node_modules,优化打包速度
}
]
},
devServer: {
host: "localhost",
port: 4399,
open: true,
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new CleanWebpackPlugin('dist'),
new HtmlWebpackPlugin({
template: "./src/index.html",
hash: true // 会在打包好的bundle.js后面加上hash串
})
]
};