Files
replayweb.page/webpack.config.js
T
Ilya Kreymer 0c737101c2 loading + fidelity fix:
- loading: Support loading URLs without extension (including blob: urls), automated type detection of WACZ, WARC, compressed and uncompressed (via wabac.js)
 - fidelity: Improved handling of ESM modules, cookies, Vimeo videos (via wabac.js)
 - dependencies: Update to wabac.js 2.15.0, wombat 3.4.3
bump to 1.7.11
2023-01-15 11:17:06 -08:00

162 lines
3.7 KiB
JavaScript

/*eslint-env node */
const path = require("path");
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const package_json = require("./package.json");
// helper proxy URL, run locally for app
const HELPER_PROXY = "https://helper-proxy.webrecorder.workers.dev";
// GDrive client-id
const GDRIVE_CLIENT_ID = "160798412227-tko4c82uopud11q105b2lvbogsj77hlg.apps.googleusercontent.com";
// Copyright banner text
const BANNER_TEXT = `'[name].js is part of ReplayWeb.page (https://replayweb.page) Copyright (C) 2020-${new Date().getFullYear()}, Webrecorder Software. Licensed under the Affero General Public License v3.'`;
const optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
};
const electronMainConfig = (/*env, argv*/) => {
return {
target: "electron-main",
mode: "production",
entry: {
"electron": "./src/electron-main.js",
},
optimization,
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
},
node: {
__dirname: false,
__filename: false,
},
plugins: [
new webpack.DefinePlugin({
__HELPER_PROXY__ : JSON.stringify(HELPER_PROXY),
}),
new webpack.BannerPlugin(BANNER_TEXT),
new CopyPlugin({
patterns: [
// { from: "node_modules/classic-level/prebuilds/", to: "prebuilds" },
{ from: "build/extra_prebuilds/", to: "prebuilds" }
],
}),
],
};
};
const electronPreloadConfig = (/*env, argv*/) => {
return {
target: "electron-preload",
mode: "production",
entry: {
"preload": "./src/electron-preload.js",
},
optimization,
plugins: [
new webpack.BannerPlugin(BANNER_TEXT),
]
};
};
const browserConfig = (/*env, argv*/) => {
return {
target: "web",
mode: "production",
resolve: {fallback: { "crypto": false }},
entry: {
"ui": "./src/ui.js",
"sw": "./src/sw.js"
},
optimization,
output: {
path: path.join(__dirname),
filename: "[name].js",
libraryTarget: "self",
globalObject: "self",
publicPath: "/"
},
devServer: {
compress: true,
port: 9990,
open: false,
static: path.join(__dirname),
//publicPath: "/"
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^node:*/,
(resource) => {
switch (resource.request) {
case "node:stream":
resource.request = "stream-browserify";
break;
}
},
),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
__SW_NAME__: JSON.stringify("sw.js"),
__HELPER_PROXY__ : JSON.stringify(HELPER_PROXY),
__GDRIVE_CLIENT_ID__ : JSON.stringify(GDRIVE_CLIENT_ID),
__VERSION__: JSON.stringify(package_json.version),
}),
new webpack.BannerPlugin(BANNER_TEXT),
new CopyPlugin({
patterns: [
{ from: "package.json", to: "_data/package.json" }
]
}),
],
module: {
rules: [
{
test: /\.svg$/,
use: ["svg-inline-loader"],
},
{
test: /main.scss$/,
use: ["css-loader", "sass-loader"]
},
{
test: /wombat.js|wombatWorkers.js|index.html$/i,
use: ["raw-loader"],
}
]
},
};
};
module.exports = [ browserConfig, electronMainConfig, electronPreloadConfig ];