初始化项目
This commit is contained in:
21
vite.config.ts
Normal file
21
vite.config.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
// Load env file based on `mode` in the current working directory.
|
||||
// Cast process to any to fix property 'cwd' does not exist on type 'Process' error
|
||||
const env = loadEnv(mode, (process as any).cwd(), '');
|
||||
|
||||
return {
|
||||
plugins: [react()],
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: false
|
||||
},
|
||||
// This defines global constants that are replaced at build time
|
||||
define: {
|
||||
'process.env.API_KEY': JSON.stringify(env.VITE_API_KEY || process.env.VITE_API_KEY || '')
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user