-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.babel.js
101 lines (98 loc) · 2.61 KB
/
webpack.common.babel.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import webpack from "webpack";
import path from "path";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import HtmlWebpackPlugin from "html-webpack-plugin";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
import pack from "./package.json";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const revision = require("child_process")
.execSync("git rev-parse --short HEAD")
.toString()
.trim();
const config = {
entry: {
psyche: path.resolve(__dirname, "src/Main.tsx"),
},
optimization: {
runtimeChunk: true,
moduleIds: "deterministic",
splitChunks: {
maxInitialRequests: Infinity,
maxAsyncRequests: Infinity,
cacheGroups: {
defaultVendors: {
chunks: "initial",
name: "vendors",
test: /[\\/]node_modules[\\/]/,
enforce: true,
},
},
},
},
module: {
rules: [
{
test: /\.[tj]sx?$/,
include: path.resolve(__dirname, "src"),
use: {
loader: "babel-loader",
},
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"],
},
{
test: /\.(png|svg|jpg|gif)$/,
type: "asset/resource",
generator: {
filename: "assets/images/[hash][ext][query]",
},
},
{
test: /\.(eot|ttf|otf|woff(2)?)(\?[a-z0-9]+)?$/,
type: "asset/resource",
generator: {
filename: "assets/fonts/[hash][ext][query]",
},
},
],
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
alias: {
"@": path.resolve(__dirname, "src"),
},
fallback: {
// stream: require.resolve("stream-browserify"),
// zlib: require.resolve("browserify-zlib"),
// util: require.resolve("util/"),
// buffer: require.resolve("buffer/"),
// assert: require.resolve("assert/"),
},
},
output: {
filename: "[name].bundle.js",
chunkFilename: "[name].bundle.js",
path: path.resolve(__dirname, "./dist/"),
publicPath: "/",
},
plugins: [
new webpack.ProgressPlugin(),
new ForkTsCheckerWebpackPlugin(),
new MiniCssExtractPlugin({
filename: "[name].bundle.css",
}),
new HtmlWebpackPlugin({
template: "src/templates/index.html",
favicon: "src/assets/images/favicon.ico",
minify: true,
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pack.version),
BUILD_HASH: JSON.stringify(revision),
}),
new webpack.BannerPlugin(`Open Sesame v${pack.version}.${revision}`),
],
};
export default config;