fix: dashboard build errors about API_URL/.env

This commit is contained in:
Dragory 2024-04-06 09:53:28 +00:00
parent 4b63d03bdb
commit 4c21884016
No known key found for this signature in database
3 changed files with 22 additions and 39 deletions

View file

@ -1,9 +1,11 @@
const path = require("path");
const { VueLoaderPlugin } = require("vue-loader");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DotenvPlugin = require("dotenv-webpack");
const { merge } = require("webpack-merge");
const webpack = require("webpack");
const dotenv = require("dotenv");
dotenv.config({ path: path.resolve(process.cwd(), "../.env") });
const targetDir = path.normalize(path.join(__dirname, "dist"));
@ -12,6 +14,11 @@ if (!process.env.NODE_ENV) {
process.exit(1);
}
if (!process.env.API_URL) {
console.error("API_URL missing from environment variables");
process.exit(1);
}
const babelOpts = {
presets: ["@babel/preset-env"],
};
@ -150,9 +157,6 @@ let config = {
js: ["./src/main.ts"],
},
}),
new DotenvPlugin({
path: path.resolve(process.cwd(), "../.env"),
}),
new webpack.EnvironmentPlugin(["API_URL"]),
],
resolve: {