-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwebpack.common.ts
More file actions
77 lines (75 loc) · 2.17 KB
/
webpack.common.ts
File metadata and controls
77 lines (75 loc) · 2.17 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
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
import path from "path";
import webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
import CopyWebpackPlugin from "copy-webpack-plugin";
import "webpack-dev-server";
const config: webpack.Configuration = {
entry: "./src/index.tsx",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].bundle.js",
clean: true,
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
"src": path.resolve(__dirname, "src/"),
"assets": path.resolve(__dirname, "assets/"),
"components": path.resolve(__dirname, "src/components/"),
"css": path.resolve(__dirname, "src/css/"),
"img": path.resolve(__dirname, "src/img/"),
},
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpg)$/,
type: "asset/resource",
generator: {
filename: "img/[hash][ext]",
}
},
{
test: /\.(png|jpg|svg)$/,
type: "asset/inline",
resourceQuery: /inline/,
},
{
test: /\.svg$/,
issuer: /\.tsx?$/,
resourceQuery: /url/,
type: "asset/resource",
generator: {
filename: "img/[hash][ext]",
}
},
{
test: /\.svg$/,
issuer: /\.tsx?$/,
resourceQuery: { not: [/(url|inline)/] },
use: ["@svgr/webpack"],
}
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
output: "./index.html",
favicon: "./src/img/favicon.png",
}),
new CopyWebpackPlugin({
patterns: [
{ from: "assets/emoji/15x15", to: "assets/emoji/15x15" },
],
}),
]
};
export default config;