remotely-save/webpack.config.js

80 lines
2.4 KiB
JavaScript
Raw Normal View History

2021-12-01 02:10:39 +00:00
require("dotenv").config();
2021-11-30 17:49:29 +00:00
const path = require("path");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
2021-12-01 02:10:39 +00:00
const DEFAULT_DROPBOX_APP_KEY = process.env.DROPBOX_APP_KEY || "";
2021-11-30 17:49:29 +00:00
module.exports = {
entry: "./src/main.ts",
target: "web",
output: {
filename: "main.js",
path: __dirname,
libraryTarget: "commonjs",
},
plugins: [
2021-12-01 02:10:39 +00:00
new webpack.DefinePlugin({
"process.env.DEFAULT_DROPBOX_APP_KEY": `"${DEFAULT_DROPBOX_APP_KEY}"`,
}),
2021-11-30 17:49:29 +00:00
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
],
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
2021-12-11 14:45:21 +00:00
{
test: /\.svg?$/,
type: "asset/source",
},
2021-11-30 17:49:29 +00:00
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
mainFields: ["browser", "module", "main"],
fallback: {
// assert: require.resolve("assert"),
// buffer: require.resolve("buffer/"),
// console: require.resolve("console-browserify"),
// constants: require.resolve("constants-browserify"),
// crypto: require.resolve("crypto-browserify"),
crypto: false,
2021-11-30 17:49:29 +00:00
// domain: require.resolve("domain-browser"),
// events: require.resolve("events"),
// http: require.resolve("stream-http"),
// https: require.resolve("https-browserify"),
// os: require.resolve("os-browserify/browser"),
path: require.resolve("path-browserify"),
// punycode: require.resolve("punycode"),
process: require.resolve("process/browser"),
// querystring: require.resolve("querystring-es3"),
stream: require.resolve("stream-browserify"),
// string_decoder: require.resolve("string_decoder"),
// sys: require.resolve("util"),
// timers: require.resolve("timers-browserify"),
// tty: require.resolve("tty-browserify"),
// url: require.resolve("url"),
// util: require.resolve("util"),
// vm: require.resolve("vm-browserify"),
// zlib: require.resolve("browserify-zlib"),
},
},
externals: {
obsidian: "commonjs2 obsidian",
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin({ extractComments: false })],
},
};