-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
89 lines (85 loc) · 2.34 KB
/
webpack.config.js
File metadata and controls
89 lines (85 loc) · 2.34 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
const fs = require("fs");
const path = require("path");
const PreactRefreshPlugin = require("@prefresh/webpack");
const localPinboardHostname = "pinboard.local.dev-gutools.co.uk";
const readCertFile = (extension) =>
fs.readFileSync(
path.join(
process.env.HOME,
`/.gu/mkcert/${localPinboardHostname}.${extension}`
)
);
module.exports = (env, argv) => {
const isDevelopment = argv.mode === "development";
return {
entry: "./src/entry.tsx",
devtool: "source-map", // TODO consider different types of source map between dev & prod
plugins: isDevelopment ? [new PreactRefreshPlugin()] : [],
devServer: isDevelopment
? {
allowedHosts: [".local.dev-gutools.co.uk"],
server: {
type: "https",
options: {
key: readCertFile("key"),
cert: readCertFile("crt"),
},
},
port: "auto",
hot: "only",
liveReload: false,
devMiddleware: {
writeToDisk: true, // so bootstrapping-lambda can find the main js filename
},
client: {
webSocketURL: "wss://pinboard.local.dev-gutools.co.uk:8081/ws",
overlay: true,
},
}
: undefined,
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/preset-typescript",
[
"@emotion/babel-preset-css-prop", // replaces @babel/preset-react
{ autoLabel: "always" },
],
"@babel/preset-env",
],
},
},
exclude: /node_modules/,
},
{
test: /\.svg$/,
use: ["@svgr/webpack"],
},
{
test: /\.(jpe?g|png)/,
type: "asset/inline",
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx"],
alias: {
react: "preact/compat",
"react-dom": "preact/compat",
},
},
output: {
clean: {
keep: /push-notifications/, // allow service-worker webpack to clean its own dist dir
},
library: "PinBoard",
filename: "pinboard.main.[contenthash].js",
path: path.resolve(__dirname, "dist"),
},
};
};