-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.config.ts
68 lines (64 loc) · 1.63 KB
/
webpack.prod.config.ts
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
import path from "path";
import webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
import { CleanWebpackPlugin } from "clean-webpack-plugin";
const CreateFilePlugin = require("create-file-webpack");
const CopyPlugin = require("copy-webpack-plugin");
import { withComponentControls } from "@component-controls/react-router-integration/webpack-build";
const publicFolder = process.env.PUBLIC_PATH || "public";
const distFolder = process.env.BUILD_PATH || "build";
const distPath = path.join(__dirname, distFolder);
const config: webpack.Configuration = {
mode: "production",
entry: "./src/index.tsx",
output: {
path: distPath,
filename: "[name].[contenthash].js",
publicPath: "",
},
module: {
rules: [
{
test: /\.(ts|js)x?$/i,
include: /src/,
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
],
},
},
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
plugins: [
new HtmlWebpackPlugin({
template: "src/index.html",
}),
new CopyPlugin({
patterns: [{ from: publicFolder }],
}),
new CleanWebpackPlugin(),
new CreateFilePlugin({
path: distFolder,
fileName: "_redirects",
content: `
/* /index.html 200
`,
}),
],
performance: {
maxEntrypointSize: 2000000,
maxAssetSize: 2000000,
},
};
export default withComponentControls({
config,
options: { configPath: ".config", distFolder: publicFolder },
});