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
67
68
69
70
| import { defineConfig } from 'vite'
| import vue from '@vitejs/plugin-vue'
| import AutoImport from 'unplugin-auto-import/vite'
| import Components from 'unplugin-vue-components/vite'
| import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
| import ElementPlus from 'unplugin-element-plus/vite'
| import path from "path";
|
| export default defineConfig({
| plugins: [
| vue(),
| AutoImport({
| resolvers: [ElementPlusResolver()],
| imports:["vue","vue-router"]//自动引入vue vue-router相关函数
| }),
| Components({
| resolvers: [ElementPlusResolver()],
| }),
| ElementPlus({
| useSource: true,
| }),
| ],
| server: {
| host: "127.0.0.1",
| https: false,//是否启用 http 2
| open: true,//为开发服务器配置 CORS ,默认启用并允许任何源Cors:open: true,//服务启动时自动在测览器中打开应用
| port: "3000",
| strictPort: false,//设为true时端口被占用则直接退出,不会尝试下一个可用端口force: true,//是否强制依赖预构建
| hmr: true,//禁用或配置 HMR 连接
| proxy: {
| '/Api': {
| target: 'https://ycm.51zhengcai.com/', //接口域名 https://ycm.51zhengcai.com/ http://192.168.0.9:2015/ http://192.168.0.36:2015/
| changeOrigin: true, //是否跨域
| secure: true, //是否https接口
| rewrite: path => path.replace(/^\/Api/, ''),
| bypass(req, res, options) {//真实地址
| const proxyUrl = new URL(req.url || "", options.target)?.href || "";
| res.setHeader("x-res-proxyUrl", proxyUrl);
| },
| },
| }
|
| },
| resolve: {
| // 配置路径别名
| alias: {
| '@': path.resolve(__dirname, './src'),
| },
| },
| css: {
| preprocessorOptions: {
| scss: {
| additionalData: `@use "@/styles/element/index.scss" as *;`,
| },
| },
| // postcss: {
| // plugins: [
| // require('autoprefixer')({
| // overrideBrowserslist: [
| // 'Android 4.1',
| // 'iOS 7.1',
| // 'Chrome > 31',
| // 'ff > 31',
| // 'ie >= 8'
| // ]
| // })
| // ]
| // }
| },
| })
|
|