-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cjs
74 lines (71 loc) · 1.81 KB
/
webpack.config.cjs
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
/* eslint-disable */
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require("webpack");
var PACKAGE = require("./package.json");
var version = PACKAGE.version;
const config = {
entry: path.join(__dirname, "src", "index.tsx"),
target: "web",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.ttf$/i,
type: "asset/resource",
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
"@blueprintjs": path.resolve(__dirname, "./node_modules/@blueprintjs"),
},
modules: [path.join(__dirname, "./src"), path.join(__dirname, "./node_modules")],
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "build", "static"),
publicPath: "/static/",
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "index.html"),
filename: path.join(__dirname, "build", "index.html"),
}),
new webpack.EnvironmentPlugin({ API_URL: null }),
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
WEB_VERSION: JSON.stringify(version),
}),
],
};
module.exports = (env, argv) => {
if (argv.mode === "development") {
config.devtool = "inline-source-map";
config.devServer = {
static: path.join(__dirname, "build"),
hot: true,
port: 3002,
historyApiFallback: {
index: "index.html",
},
};
} else if (argv.mode === "production") {
config.optimization = {
splitChunks: {
chunks: "all",
},
};
}
return config;
};