-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
42 lines (41 loc) · 1.23 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
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const Dotenv = require("dotenv-webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
mode: "development", // or 'production' for production builds
entry: {
index: "./src/index.js", // Entry point for popup.js
},
output: {
filename: "[name].js", // Output bundle files
path: path.resolve(__dirname, "dist"), // Output directory is 'dist'
publicPath: "/", // Serve files from the root directory
},
plugins: [
new Dotenv(), // Load environment variables from .env file
new HtmlWebpackPlugin({
template: "./src/public/index.html", // Use a template HTML file
}),
],
devServer: {
port: 8080, // Specify the port
open: true, // Open the browser on start
hot: true, // Enable Hot Module Replacement
historyApiFallback: true, // Support client-side routing (e.g., React Router)
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader", // Optionally use Babel to transpile JS
options: {
presets: ["@babel/preset-env"],
},
},
},
],
},
};