-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.config.js
37 lines (35 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
const path = require("path");
module.exports = (env, argv) => {
const mode = argv.mode || "development"; // Default mode is development
const isProduction = mode === "production";
return {
entry: "./app.js",
output: {
// Use different paths for development and production
path: isProduction
? path.resolve(__dirname, "dist/public")
: path.resolve(__dirname, "public"),
filename: "bundle.js",
},
mode: mode,
devtool: isProduction ? "source-map" : "eval-source-map",
module: {
rules: [
{
test: /\.jsx?$/, // Match both .js and .jsx files
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: ["@babel/plugin-proposal-class-properties"],
},
},
},
],
},
resolve: {
extensions: [".js", ".jsx"], // Automatically resolve .js and .jsx files
},
};
};