-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
47 lines (45 loc) · 1.21 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'), //路径别名
}
},
server:{
proxy: {
'/api': {
target: 'https://4wso1r5il4.execute-api.cn-northwest-1.amazonaws.com.cn', // 后端 API 地址
changeOrigin: true, // 是否改变请求头中的 origin
rewrite: (path) => path.replace(/^\/api/, '') // 重写路径
}
}
},
build: {
// 添加这个配置
rollupOptions: {
input: path.resolve(__dirname, 'index.html') //指定 Rollup 的入口点。这里设置为项目根目录下的 index.html 文件
}
},
optimizeDeps: {
include: ['vue', 'vue-router', 'pinia']
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/variables.scss" as variables;`, //全局导入
importer(url: string): { file: string } | null {
if (url[0] !== '@') {
return null;
}
return {
file: `${path.resolve(__dirname, './src')}${url.slice(1)}`
}
}
}
}
}
// ... 其他配置
})