-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
61 lines (60 loc) · 1.61 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
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = env => ({
mode: env.production ? "development" : "development",
entry: env.production ? "./src/index.js" : ["webpack/hot/dev-server", "./src/index.js"],
output: {
path: path.resolve(__dirname, "./dist"),
filename: "main.js",
sourceMapFilename: "main.map",
libraryTarget: "umd"
},
optimization: {
minimize: true
},
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin([
{ from: "index.html", to: "index.html" },
{ from: "styles", to: "styles" },
{ from: "images", to: "images" },
{ from: "audio", to: "audio" },
])
],
watch: env.development,
devtool: env.production ? false : "source-map",
devServer: {
open: true,
writeToDisk: true,
contentBase: [path.join(__dirname, "./"), path.join(__dirname, "./dist")],
historyApiFallback: true,
https: true,
host: "192.168.0.104",
port: 3000,
hot: true
},
module: {
rules: [
{
test: /\.js$/,
include: /src/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
plugins: [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-optional-chaining"
]
}
}
]
}
]
},
externals: ["node-fetch", "form-data"]
});