inject env var in webpack

This commit is contained in:
fyears 2021-12-01 10:10:39 +08:00
parent 2930fe5350
commit ccd3b49b4b

View File

@ -1,7 +1,10 @@
require("dotenv").config();
const path = require("path");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
const DEFAULT_DROPBOX_APP_KEY = process.env.DROPBOX_APP_KEY || "";
module.exports = {
entry: "./src/main.ts",
target: "web",
@ -11,6 +14,9 @@ module.exports = {
libraryTarget: "commonjs",
},
plugins: [
new webpack.DefinePlugin({
"process.env.DEFAULT_DROPBOX_APP_KEY": `"${DEFAULT_DROPBOX_APP_KEY}"`,
}),
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({