-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
52 lines (48 loc) · 1.29 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 path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
const SRC_DIR = path.resolve(__dirname, "src");
const BUILD_DIR = path.resolve(__dirname, "build");
module.exports = (env) => {
const entry = SRC_DIR + "/" + (env.entry ? env.entry : "index.js");
const outputName = env.outputName ? env.outputName : "bundle.js";
const inlineHtml = env.inlineHtml ? env.inlineHtml : "index.html";
console.log("entry:", entry);
console.log("outputName:", outputName);
console.log("inlineHtml:", inlineHtml);
return {
entry: entry,
output: {
path: BUILD_DIR,
filename: outputName
},
module: {
rules: [
{
test: /\.js$/,
include: [SRC_DIR],
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"]
}
}
]
},
resolve: {
extensions: [".js"],
alias: {
"~": SRC_DIR
}
},
plugins: [
new HtmlWebpackPlugin({
filename: inlineHtml,
meta: {
viewport: "initial-scale=1, maximum-scale=1"
},
inlineSource: ".(js|css)$"
}),
new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin)
]
};
};