fix: make URL environment variable work during build
This commit is contained in:
@@ -1,15 +1,21 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
plugins: [react()],
|
const env = loadEnv(mode, process.cwd(), "");
|
||||||
define: {
|
|
||||||
__VITE_API_BASE_URL__: "import.meta.env.VITE_API_BASE_URL",
|
return {
|
||||||
},
|
plugins: [react()],
|
||||||
css: {
|
define: {
|
||||||
modules: {
|
__VITE_API_BASE_URL__: env.VITE_API_BASE_URL
|
||||||
localsConvention: "camelCase",
|
? JSON.stringify(env.VITE_API_BASE_URL)
|
||||||
}
|
: "undefined",
|
||||||
},
|
},
|
||||||
|
css: {
|
||||||
|
modules: {
|
||||||
|
localsConvention: "camelCase",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user