This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
100 lines (85 loc) · 2.7 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
/*eslint-env node */
//const path = require("path");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const PACKAGE = require("./package.json");
const AWP_PACKAGE = require("./node_modules/@webrecorder/archivewebpage/package.json");
const WARCIO_PACKAGE = require("./node_modules/warcio/package.json");
const DEFAULT_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDREMEMxYjlCNzdDOTYxMTA4NkU2NDMzOTI0NDM3Rjc1MGRBNjVlNTciLCJpc3MiOiJ3ZWIzLXN0b3JhZ2UiLCJpYXQiOjE2NDYyOTExMjU3MzAsIm5hbWUiOiJhd3BleHByZXNzIn0.oxSNKwda3IhOxfyjaq8Jva7RblPilsPMa9vV8bkzWVI";
const TOKEN = process.env.TOKEN || DEFAULT_TOKEN;
const RWP_PREFIX = "https://cdn.jsdelivr.net/npm/[email protected]/";
module.exports = {
target: "web",
entry: {
main: "./src/index.js",
sw: "./src/sw/sw.js",
},
output: {
filename: "[name].js",
path: __dirname,
libraryTarget: "self",
globalObject: "self",
},
resolve: {
fallback: {
"stream": require.resolve("stream-browserify"),
}
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
},
plugins: [
new webpack.BannerPlugin("[name].js is part of Webrecorder project. Copyright (C) 2020-2021, Webrecorder Software. Licensed under the Affero General Public License v3."),
new webpack.DefinePlugin({
__IPFS_CORE_URL__: JSON.stringify("https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"),
__TOKEN__: JSON.stringify(TOKEN),
__AWP_EXPRESS_VERSION__: JSON.stringify(PACKAGE.version),
__AWP_VERSION__: JSON.stringify(AWP_PACKAGE.version),
__WARCIO_VERSION__: JSON.stringify(WARCIO_PACKAGE.version),
__RWP_PREFIX__ : JSON.stringify(RWP_PREFIX),
}),
new webpack.ProvidePlugin({
process: "process/browser.js",
Buffer: ["buffer", "Buffer"],
}),
new CopyPlugin({
patterns: [
// Copy Shoelace assets to dist/shoelace
{
from: "node_modules/@shoelace-style/shoelace/dist/assets",
to: "shoelace/assets"
},
{
from: "node_modules/browsertrix-behaviors/dist/behaviors.js",
to: "assets/behaviors.js"
}
]
})
],
module: {
rules: [
{
test: /wombat.js|wombatWorkers.js|index.html$/i,
use: ["raw-loader"],
},
{
test: /\.css$/,
use: [
"style-loader",
{ loader: "css-loader", options: { importLoaders: 1 } },
"postcss-loader",
],
}
]
},
externals: {
"bufferutil": "bufferutil",
"utf-8-validate": "utf-8-validate",
}
};