-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
102 lines (101 loc) · 3.05 KB
/
webpack.config.js
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
101
102
const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require("webpack")
if (process.env.NODE_ENV === "development") { require("dotenv").config(); }
module.exports = {
entry: "./src/index.tsx",
mode: process.env.NODE_ENV || "production",
output: {
path: path.resolve(__dirname, "build"),
filename: "[name].bundle.js",
sourceMapFilename: "[name].bundle.js.map",
publicPath: "/",
devtoolModuleFilenameTemplate: "[resource-path]"
},
devtool: "source-map",
optimization: {
splitChunks: {
chunks: 'all',
maxSize: 204800,
}
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
module: {
rules: [{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "swc-loader",
options: {
jsc: {
parser: {
syntax: "ecmascript",
jsx: true,
dynamicImport: true
},
transform: {
react: {
pragma: "React.createElement",
pragmaFrag: "React.Fragment",
throwIfNamespace: true,
development: false,
useBuiltins: false
}
}
}
}
}
}, {
test: /\.tsx?$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "swc-loader",
options: {
jsc: {
parser: {
syntax: "typescript",
tsx: true,
dynamicImport: true
}
}
}
}
}, {
test: /\.svg$/,
loader: '@svgr/webpack'
}]
},
devServer: {
compress: true,
port: 3000,
historyApiFallback: true,
},
plugins: [
new CopyPlugin({
patterns: [{
from: 'public',
to: '.',
globOptions: {
ignore: [
'**/index.html'
]
}
}, ],
}), new webpack.EnvironmentPlugin({
NODE_ENV: "production",
BRANCH: "development",
COMMIT_REF: "development",
REACT_APP_SENTRY_DSN: "https://false@notreal.ingest.sentry.io/1234",
REACT_APP_OAUTH2_CLIENT_ID: "0",
BACKEND_URL: "https://forms-api.pythondiscord.com/",
CONTEXT: "development"
}), new HtmlWebpackPlugin({
inject: true,
template: 'public/index.html'
}), new webpack.SourceMapDevToolPlugin({
filename: "[file].map[query]"
})]
}