-
Notifications
You must be signed in to change notification settings - Fork 35
/
webpack.config.js
45 lines (43 loc) · 1.01 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
const { execSync } = require("child_process");
const path = require("path");
const webpack = require("webpack");
const DEV = process.env.DEBUG === "1";
module.exports = {
mode: DEV ? "development" : "production",
entry: {
main: "./src/main.js",
demo: "./src/demo.js",
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "dist"),
},
devtool: DEV ? "inline-source-map" : undefined,
devServer: {
static: ["./", "./resources"],
},
module: {
rules: [
{
test: /\.?js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
],
},
plugins: [
new webpack.DefinePlugin({
_DEBUG_: JSON.stringify(process.env.DEBUG === "1"),
_HASH_: JSON.stringify(execSync("git rev-parse --short HEAD").toString()),
}),
],
};