-
-
Notifications
You must be signed in to change notification settings - Fork 973
/
Copy pathvite.config.mjs
66 lines (63 loc) · 1.42 KB
/
vite.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'node:path'
import autoprefixer from 'autoprefixer'
export default defineConfig(({ mode }) => {
// Load .env
const viteEnv = loadEnv(mode, process.cwd(), '')
const env = {}
// Filter env to variables starting with VITE_APP or VUE_APP
Object.keys({...process.env, ...viteEnv}).forEach(key => {
if (key.startsWith('VITE_APP') || key.startsWith('VUE_APP')) {
env[key] = viteEnv[key]
}
})
return {
plugins: [vue()],
base: './',
css: {
postcss: {
plugins: [
autoprefixer({}) // add options if needed
],
}
},
resolve: {
alias: [
// webpack path resolve to vitejs
{
find: /^~(.*)$/,
replacement: '$1',
},
{
find: '@/',
replacement: `${path.resolve(__dirname, 'src')}/`,
},
{
find: '@',
replacement: path.resolve(__dirname, '/src'),
},
],
extensions: [
'.mjs',
'.js',
'.ts',
'.jsx',
'.tsx',
'.json',
'.vue',
'.scss',
],
},
server: {
port: 3000,
proxy: {
// https://vitejs.dev/config/server-options.html
},
},
define: {
// vitejs does not support process.env so we have to redefine it
'process.env': env,
},
}
})