Skip to content

Commit

Permalink
Merge pull request #6516 from getkirby/v5/fix/vite-env
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle authored Jun 28, 2024
2 parents 23a46e5 + c1a1da3 commit 5d84c2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion panel/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VUE_APP_DEV_SERVER = "http://sandbox.test"
SERVER = "http://sandbox.test"
13 changes: 10 additions & 3 deletions panel/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env node */
import path from "path";

import { defineConfig, splitVendorChunkPlugin } from "vite";
import { defineConfig, loadEnv, splitVendorChunkPlugin } from "vite";
import vue from "@vitejs/plugin-vue2";
import { viteStaticCopy } from "vite-plugin-static-copy";
import externalize from "rollup-plugin-external-globals";
Expand All @@ -21,7 +21,7 @@ function createAliases() {
*/
function createServer() {
const proxy = {
target: process.env.VUE_APP_DEV_SERVER ?? "http://sandbox.test",
target: process.env.SERVER ?? "http://sandbox.test",
changeOrigin: true,
secure: false
};
Expand Down Expand Up @@ -99,7 +99,14 @@ function createTest() {
/**
* Returns the Vite configuration
*/
export default defineConfig(({ command }) => {
export default defineConfig(({ command, mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
process.env = {
...process.env,
...loadEnv(mode, process.cwd(), '')
};

return {
plugins: createPlugins(command),
define: {
Expand Down

0 comments on commit 5d84c2d

Please sign in to comment.