This repository was archived by the owner on Aug 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
57 lines (55 loc) · 1.54 KB
/
Copy pathwebpack.config.js
File metadata and controls
57 lines (55 loc) · 1.54 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
const path = require("path");
const glob = require("glob");
const TerserPlugin = require("terser-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
// One entry per src/<template>/index.tsx -> build/<template>.js (global PRSSComponent)
const entry = glob.sync("src/*/index.+(js|jsx|ts|tsx)").reduce((acc, file) => {
const norm = file.split(path.sep).join("/");
const parts = norm.split("/");
const key = parts[parts.indexOf("src") + 1];
acc[key] = "./" + norm;
return acc;
}, {});
module.exports = {
mode: "production",
entry,
devtool: "source-map",
output: {
filename: "[name].js",
path: path.resolve(__dirname, "build"),
libraryTarget: "var",
library: "PRSSComponent",
clean: true
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin(), new CssMinimizerPlugin()]
},
module: {
rules: [
{
test: /\.m?js(x?)|ts(x?)$/,
exclude: /(node_modules|bower_components)/,
use: { loader: "babel-loader" }
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
}
]
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: { "@": path.resolve(__dirname, "src/_common") }
},
performance: { hints: false },
externals: {
prss: "PRSS",
"@prss/ui": "PRSS",
react: "React",
"react-dom": "ReactDOM",
"react-dom/client": "ReactDOM"
},
plugins: [new MiniCssExtractPlugin({ filename: "theme.css" })]
};