-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.client.js
87 lines (85 loc) · 1.98 KB
/
webpack.config.client.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const { ESBuildMinifyPlugin } = require("esbuild-loader");
const { ProvidePlugin, DefinePlugin } = require("webpack");
const MOCK_ENV = process.env.MOCK_ENV || "off";
const PUBLIC_GA_ID = process.env.PUBLIC_GA_ID || "";
module.exports = {
entry: path.resolve(__dirname, "./src/client/index.js"),
mode: "development",
devServer: {
static: {
directory: path.join(__dirname, "dist/client"),
},
port: 3000,
},
output: {
path: path.join(__dirname, "dist/client"),
filename: "[name].bundle.js",
chunkFilename: "[name].bundle.js",
publicPath: "auto",
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
fallback: {
util: require.resolve("util/"),
},
},
module: {
rules: [
{
test: /bootstrap\.js$/,
loader: "bundle-loader",
options: {
lazy: true,
},
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ["@svgr/webpack"],
},
{
test: /\.js$/,
loader: "esbuild-loader",
options: {
loader: "jsx",
target: "es2015",
},
},
{
test: /\.tsx?$/,
loader: "esbuild-loader",
options: {
loader: "tsx",
target: "es2015",
tsconfigRaw: require("./tsconfig.client.json"),
},
},
],
},
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
target: "es2015",
}),
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./public/index.html",
favicon: "./public/favicon.ico",
}),
new ProvidePlugin({
process: "process/browser",
}),
new DefinePlugin({
"process.env.MOCK_ENV": JSON.stringify(MOCK_ENV),
"process.env.PUBLIC_GA_ID": JSON.stringify(PUBLIC_GA_ID),
}),
],
};