-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathwebpack.config.js
More file actions
52 lines (50 loc) · 1.47 KB
/
Copy pathwebpack.config.js
File metadata and controls
52 lines (50 loc) · 1.47 KB
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
import path from "path";
import { fileURLToPath } from "url";
import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default (env = {}) => ({
mode: env.development ? "development" : "production",
entry: "./src/index.jsx",
output: {
path: path.join(__dirname, "ui_build"),
filename: "static/js/[name].[contenthash].js",
chunkFilename: "static/js/[name].[contenthash].chunk.js",
publicPath: "./",
clean: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "swc-loader",
options: {
jsc: {
parser: { syntax: "ecmascript", jsx: true },
transform: { react: { runtime: "automatic" } }
}
}
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.(woff|woff2|eot|ttf|otf|svg|png|jpg|jpeg|gif)$/i,
type: "asset/resource",
generator: { filename: "static/media/[hash][ext][query]" },
},
],
},
plugins: [
new HtmlWebpackPlugin({ template: "./public/index.html" }),
new MiniCssExtractPlugin({
filename: "static/css/[name].[contenthash].css",
chunkFilename: "static/css/[name].[contenthash].chunk.css",
}),
],
devtool: env.development ? "source-map" : false,
});