-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
69 lines (67 loc) · 1.8 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
const CopyWebpackPlugin = require("copy-webpack-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const path = require("path");
const webpack = require("webpack");
const dotenv = require("dotenv");
const envFile = process.env.NODE_ENV ? `.env.${process.env.NODE_ENV}` : ".env";
dotenv.config({ path: envFile });
const isProduction = process.env.NODE_ENV === "production";
const url = isProduction
? "${document.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${location.host}"
: "ws://${location.hostname}:7007";
module.exports = {
entry: "./app/index.tsx",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /server-url\.ts?$/,
loader: "string-replace-loader",
options: {
search: "ws://localhost:7007",
replace: url,
},
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
plugins: [
new TsconfigPathsPlugin({
/* options: see below */
}),
],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "index.js",
},
devtool: false,
mode: process.env.NODE_ENV || "development",
plugins: [
new CopyWebpackPlugin({
patterns: ["index.html", "dist/styles.css", "favicon.png"],
}),
new webpack.DefinePlugin({
"process.env.RELAY_URL": JSON.stringify("https://relay.tss.ac"),
"process.env.SNAP_ID": JSON.stringify(process.env.SNAP_ID),
}),
],
devServer: {
headers: {
"Access-Control-Allow-Origin": "*",
"Cross-Origin-Embedder-Policy": "require-corp",
"Cross-Origin-Opener-Policy": "same-origin",
},
liveReload: false,
},
experiments: {
//syncWebAssembly: true,
asyncWebAssembly: true,
//topLevelAwait: true,
},
};