-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.config.js
59 lines (50 loc) · 1.26 KB
/
webpack.dev.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
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const root_path = path.resolve(__dirname); // 项目根目录
const app_path = path.resolve(root_path,'src'); // src目录
const entry_path = path.resolve(app_path,'index.jsx'); // 入口文件
const dist_path = path.resolve(root_path,'bulid');// 打包环境目录
module.exports = {
entry: entry_path,
output: {
filename: 'bundle.js',
path: dist_path,
},
mode: 'development',
// 模块查找规则
resolve: {
extensions: [".js",".jsx", ".json", ".css",'.json5']
},
// 配置DevServer
devServer:{
contentBase: '/build',
},
// 配置需要的loader
module:{
rules:[{
test: /(\.jsx|\.js)$/,
use: ["babel-loader?presets[]=env,presets[]=react"],
exclude: /node_modules/
},{
test: /\.css$/,
use: ["style-loader","css-loader"],
exclude: /node_modules/
},{
test: /(\.png|\.jpg|\.gif)$/,
use: ["file-loader"],
exclude: /node_modules/
},{
test: /\.json5$/,
use: ["json5-loader"],
exclude: /node_modules/
}
]
},
// 配置需要的plugins
plugins:[
new HtmlWebpackPlugin({
template: app_path + "/index.html"// 入口文件HTML
}),
]
}