From b9613918e55b82ab40f0c136b389025b041be067 Mon Sep 17 00:00:00 2001 From: fyears Date: Wed, 20 Oct 2021 02:11:02 +0800 Subject: [PATCH] fallback in web --- webpack.config.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index ed2a503..d02a681 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const path = require("path"); module.exports = { entry: "./main.ts", - target: "node", + target: "web", output: { filename: "main.js", path: __dirname, @@ -20,6 +20,31 @@ module.exports = { resolve: { extensions: [".tsx", ".ts", ".js"], mainFields: ["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"), + 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",