Created
September 30, 2022 01:30
-
-
Save Fanreza/aa8922450eeada82a84f747c424e17ca to your computer and use it in GitHub Desktop.
Use .env in vite config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fileURLToPath, URL } from "url"; | |
import { defineConfig, loadEnv } from "vite"; | |
import vue from "@vitejs/plugin-vue"; | |
export default ({ mode }) => { | |
process.env = Object.assign(process.env, loadEnv(mode, process.cwd(), "")); | |
return defineConfig({ | |
plugins: [vue()], | |
base: process.env.VITE_BASE_DIRECTORY, // can be used now | |
resolve: { | |
alias: { | |
"@": fileURLToPath(new URL("./src", import.meta.url)), | |
}, | |
}, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment