forked from easy-temps/vue3-vant-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
51 lines (50 loc) · 1.37 KB
/
vite.config.ts
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
import type { ConfigEnv, UserConfig } from 'vite'
import { loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { createStyleImportPlugin } from 'vite-plugin-style-import'
import createMockServer from './build/mockServer'
// https://vitejs.dev/config/
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd()
const env = loadEnv(mode, root)
return {
base: env.VITE_APP_PUBLIC_PATH,
define: {
'process.env.VUE_APP_API_BASE_URL': JSON.stringify(env.VITE_APP_API_BASE_URL),
'process.env.VUE_APP_PUBLIC_PATH': JSON.stringify(env.VITE_APP_PUBLIC_PATH),
},
plugins: [
vue(),
createStyleImportPlugin({
resolves:[],
libs: [{
libraryName: 'vant',
esModule: false,
resolveStyle: (name) => {
return `vant/es/${name}/style/less`
}
}]
})
],
resolve: {
alias: {
'~@': path.join(__dirname, './src'),
'@': path.join(__dirname, './src'),
'~': path.join(__dirname, './src/assets'),
vue: 'vue/dist/vue.esm-bundler.js',
},
},
server: {
host: true,
proxy: {
'/api': {
// backend url
target: env.VITE_HTTP_MOCK && env.VITE_MOCK ? createMockServer() : '',
ws: false,
changeOrigin: true,
},
},
}
}
}