forked from serverless-dns/serverless-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cjs
50 lines (44 loc) · 1.16 KB
/
webpack.config.cjs
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
const webpack = require("webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
// developers.cloudflare.com/workers/cli-wrangler/configuration#modules
// archive.is/FDky9
module.exports = {
entry: "./src/server-workers.js",
target: ["webworker", "es2020"],
mode: "production",
// enable devtool in development
// devtool: 'eval-cheap-module-source-map',
// gist.github.com/ef4/d2cf5672a93cf241fd47c020b9b3066a
resolve: {
fallback: {
// buffer polyfill: archive.is/7OBM7
buffer: require.resolve("buffer/"),
},
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new webpack.IgnorePlugin({
resourceRegExp:
/(^dgram$)|(^http2$)|(\/deno\/.*\.ts$)|(.*-deno\.ts$)|(.*\.deno\.ts$)|(\/node\/.*\.js$)|(.*-node\.js$)|(.*\.node\.js$)/,
}),
// stackoverflow.com/a/65556946
new NodePolyfillPlugin(),
],
optimization: {
usedExports: true,
minimize: false,
},
experiments: {
outputModule: true,
},
// stackoverflow.com/a/68916455
output: {
library: {
type: "module",
},
filename: "worker.js",
module: true,
},
};