Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
91 lines (87 loc) · 2.05 KB
/
Copy pathwebpack.config.js
File metadata and controls
91 lines (87 loc) · 2.05 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const path = require("path");
const aliases = () => {
const aliasConfig = {
//REACT
react: path.resolve(__dirname, "./node_modules/react"),
// REACT components
Components: path.resolve(__dirname, "src/components/"),
Utils: path.resolve(__dirname, "src/utils/"),
Types: path.resolve(__dirname, "src/types/"),
Assets: path.resolve(__dirname, "src/assets/"),
};
return aliasConfig;
};
module.exports = {
entry: path.resolve(__dirname, "./src/index.ts"),
output: {
filename: "main.js",
path: path.resolve(__dirname, "dist"),
libraryTarget: "umd",
globalObject: "this",
},
resolve: {
alias: aliases(),
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
modules: ["node_modules", path.resolve(__dirname, "node_modules")],
},
externals: {
// Use external version of React
react: {
commonjs: "react",
commonjs2: "react",
amd: "react",
root: "React",
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "react-dom",
root: "ReactDOM",
},
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
["@babel/preset-react", { runtime: "automatic" }],
"@babel/preset-typescript",
],
},
},
],
},
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.(png|jpg|gif)$/,
type: "asset/resource",
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: [
{
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [{ name: "preset-default", removeViewBox: false }],
},
},
},
"file-loader",
],
},
],
},
devtool: "inline-source-map",
};