forked from Shirtiny/shWave
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.dev.config.js
72 lines (71 loc) · 1.76 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
60
61
62
63
64
65
66
67
68
69
70
71
72
const path = require("path");
const HtmlPlugin = require("html-webpack-plugin");
// const nodeExternals = require('webpack-node-externals');
module.exports = {
//模式: development production
mode: "development",
entry: {
app: path.join(__dirname, "src/index.js"),
},
output: {
filename: "shwave.boundle.js",
path: path.join(__dirname, "build"),
// libraryTarget: "commonjs2",
},
devServer: {
//热打包
hot: true,
//0.0.0.0本地host通用 , http://localhost:2021/
host: "localhost",
port: "2021",
//在出错误时 全屏显示错误
overlay: true,
},
resolve: {
modules: ["node_modules"],
extensions: [".js", ".jsx", ".json"],
enforceExtension: false,
},
module: {
rules: [
{
//以.js或.jsx结尾的文件
test: /\.(js|jsx)$/,
//排除node_modules文件夹 不打包它
exclude: path.join(__dirname, "node_modules"),
//使用babel-loader转译react的jsx代码 为es5
use: ["babel-loader"],
},
{
//以.css结尾的文件
test: /\.css$/,
//从右到左执行 对css文件先用cssloader 然后用styleloader
use: ["style-loader", "css-loader"],
},
{
test: /\.(htm|html)$/,
use: ["html-loader"],
},
{
test: /\.(ttf|woff2|woff|eot|svg|jpg|jpeg|gif|png)$/,
use: [
{
loader: "file-loader",
options: {
esModule: false,
},
},
],
},
],
},
plugins: [
new HtmlPlugin({
filename: "index.html",
//指出要打包的路径
template: path.join(__dirname, "src/index.html"),
}),
],
//插件 忽略node_modules
// externals: [nodeExternals()],
};