-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
134 lines (124 loc) · 3.39 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* @Author: chan-max [email protected]
* @Date: 2023-12-16 12:40:26
* @LastEditors: chan-max [email protected]
* @LastEditTime: 2024-02-21 22:31:41
* @FilePath: /yishe/vite.config.ts
* @Description:
*
* Copyright (c) 2023 by 1s, All Rights Reserved.
*/
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import alias from "@rollup/plugin-alias";
import { resolve } from 'path'
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'
import svgSprites from 'rollup-plugin-svg-sprites'
import { basename } from 'path';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
// 移动端扫码进入项目
import { qrcode } from 'vite-plugin-qrcode';
// 开发环境使用 https
import basicSsl from '@vitejs/plugin-basic-ssl'
// 编译文件支持旧游览器
import legacy from '@vitejs/plugin-legacy';
// import AntdvResolver from 'antdv-component-resolver'
import { quasar, transformAssetUrls } from '@quasar/vite-plugin'
import svgLoader from 'vite-svg-loader'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from "unplugin-auto-import/vite";
import { viteObfuscateFile } from 'vite-plugin-obfuscator'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
export default defineConfig((config: any) => {
const isApp = config.mode === 'app'
const isServer = config.mode === 'server'
const baseBuild = {
outDir: 'www',
assetsDir: './',
rollupOptions: {
input: {
mobile: resolve(__dirname, 'mobile.html'),
index: resolve(__dirname, 'index.html'),
},
}
}
const appBuild = {
outDir: 'app',
assetsDir: './',
rollupOptions: {
input: resolve(__dirname, 'app.html'),
}
}
return {
plugins: [
alias(),
// https dev
basicSsl(),
Components({
resolvers: [VantResolver()],
}),
qrcode(),
legacy(),
quasar({
sassVariables: 'src/style/quasar-variables.sass'
}),
vue({
template: { transformAssetUrls }
}),
svgLoader(),
vueJsx({
}),
// 自动引入
AutoImport({
imports: ["vue", "vue-router"],
dts: true
}),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), "src/icon")],
// 指定symbolId格式
symbolId: 'icon-[name]',
})
],
base: isApp ? './' : '/', // 普通路径与app路径处理方式不同
build: isApp ? appBuild : baseBuild,
css: {
postcss: {
plugins: [
tailwindcss,
autoprefixer,
]
},
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
server: {
port: 6699,
proxy: {
"/api": {
target: "https://localhost:7788",
// target: "https://1s.design:7788",
changeOrigin: true,
secure: false, // 防止证书引发的
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
resolve: {
alias: {
/* @/ 代表src 路径下 , @ 代表全局路径下 */
"@": path.resolve(__dirname, "./src"),
"@common": path.resolve(__dirname, "./common/"),
},
},
define: {
'__DEV__': process.env.NODE_ENV !== 'production',
}
}
});