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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
| import {
| defineConfig
| } from 'vite'
| import vue from '@vitejs/plugin-vue'
| import path from 'path'
| import Components from 'unplugin-vue-components/vite';
| import {
| VantResolver
| } from 'unplugin-vue-components/resolvers';
| import DefineOptions from 'unplugin-vue-define-options/vite';
| import {
| visualizer
| } from 'rollup-plugin-visualizer'
| // yyhh
| import legacy from '@vitejs/plugin-legacy';
|
|
| const isVisualizer = process.env.VISUALIZER === 'show'
| export default defineConfig({
| base: './',
| plugins: [
| vue(),
| Components({
| resolvers: [VantResolver()],
| }),
| DefineOptions(),
| isVisualizer && visualizer({
| gzipSize: true
| }),
| // yyhh
| // legacy({
| // targets: ['defaults', 'not IE 11'],
| // }),
|
| ],
| css: {
| preprocessorOptions: {
| scss: {
| additionalData: `@import "@/assets/css/variable.scss";`
| },
| }
| },
| // server: {
| // open: true,
| // port: 333,
| // hmr: true,
| // host: '0.0.0.0',
| // proxy: {
| // "/api": {
| // target: "http://api.swftek.com", //填写反向代理8085后的域名
| // changeOrigin: true,
| // secure: false
| // },
| // },
| // },
| server: {
| open: true,
| port: 333,
| host: '0.0.0.0',
| proxy: {
| // 关键:用正则表达式匹配所有含/api的路径(忽略大小写)
| '^/api.*': { // 匹配以/api开头的任何路径(如/api、/api/xxx、/api?xx等)
| // target: 'http://154.23.189.28:8086',
| target:'https://api.mak-web3.com',
| // target:'https://api.mak-web3.com',
| // target: 'https://by2.cccxxx.cc',
| changeOrigin: true,
| secure: false,
| // logLevel: 'debug', // 打印详细代理日志
| rewrite: (path) => path, // 不修改路径(如果目标API本身就有/api前缀)
| configure: (proxy) => {
| proxy.on('proxyReq', (proxyReq, req) => {
| console.log(`[代理成功] 捕获请求: ${req.method} ${req.url}`);
| });
| proxy.on('error', (err) => {
| console.log(`[代理错误] ${err.message}`);
| });
| }
| }
| }
| },
| resolve: {
| dedupe: [
| 'vue'
| ],
| alias: {
| 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
| "~": path.resolve(__dirname, './'),
| "@": path.resolve(__dirname, 'src'),
| }
| },
| build: {
| assetsDir: "static",
| chunkSizeWarningLimit: 5000, // 改为1000KiB
| // yyhh
| target: 'esnext', // 或者 'es2019' / 'es2020'
| // 明确设置支持异步生成器的目标环境
| rollupOptions: {
| input: {
| index: path.resolve(__dirname, "index.html"),
| },
| output: {
| chunkFileNames: 'js/[name]-[hash].js',
| entryFileNames: "js/[name]-[hash].js",
| assetFileNames: "[ext]/[name]-[hash].[ext]"
| },
| },
| },
| externals: ['vue']
| })
|
|