36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import {fileURLToPath, URL} from 'node:url'
|
|
import {defineConfig, loadEnv} from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import svgLoader from 'vite-svg-loader'
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({mode}) => {
|
|
// Load environment variables based on the mode
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
return {
|
|
plugins: [
|
|
vue(),
|
|
svgLoader()
|
|
],
|
|
server: {
|
|
https: {
|
|
key: fs.readFileSync(path.resolve(__dirname, 'c:/git/localhost-key.pem')),
|
|
cert: fs.readFileSync(path.resolve(__dirname, 'c:/git/localhost.pem')),
|
|
},
|
|
host: 'localhost',
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
},
|
|
define: {
|
|
// Define a global constant __APP_ENV__ based on loaded environment variables
|
|
VITE_API_URL: JSON.stringify(env.VITE_API_URL),
|
|
VITE_STRIPE_API_KEY: JSON.stringify(env.VITE_STRIPE_API_KEY)
|
|
}
|
|
}
|
|
})
|