-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.common.cjs
100 lines (99 loc) · 2.49 KB
/
webpack.common.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
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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
require("dotenv").config({ path: "./.env" });
const config = {
entry: {
main: path.join(__dirname, "src", "index.tsx"),
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
type: "asset",
},
{
test: /\.css$/i,
include: path.resolve(__dirname, "src"),
use: ["style-loader", "css-loader"],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource",
},
{
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
},
{
test: /\.ya?ml$/,
use: "yaml-loader",
},
],
},
resolve: {
extensions: [".js", ".tsx", ".ts"],
fallback: {
fs: false,
},
},
plugins: [
new webpack.ProgressPlugin(),
new CleanWebpackPlugin({
verbose: true,
cleanStaleWebpackAssets: true,
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "index.html"),
}),
new CopyPlugin({
patterns: [{ from: "public" }],
}),
new CopyPlugin({
patterns: [
{
from: path.join(__dirname, "public", "manifest.json"),
to: path.join(__dirname, "build"),
force: true,
transform: function (content, path) {
// generates the manifest file using the package.json information
return Buffer.from(
JSON.stringify({
description: process.env.npm_package_description,
version: process.env.npm_package_version,
...JSON.parse(content.toString()),
})
);
},
},
],
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version),
"process.env": JSON.stringify(process.env)
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new NodePolyfillPlugin(),
],
infrastructureLogging: {
level: "info",
},
experiments: {
asyncWebAssembly: true,
},
};
module.exports = config;