159 lines
4.7 KiB
TypeScript
159 lines
4.7 KiB
TypeScript
/*
|
|
* vvts, is framework use vue3.0 + vite + typescript.
|
|
* Copyright (C) $today.years guoqing22
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import { defineConfig } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
import { resolve } from "path";
|
|
import path from "path";
|
|
|
|
import AutoImport from "unplugin-auto-import/vite";
|
|
import Components from "unplugin-vue-components/vite";
|
|
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
|
function _resolve(dir: string) {
|
|
return path.resolve(__dirname, dir);
|
|
}
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
visualizer({
|
|
gzipSize: true,
|
|
brotliSize: true,
|
|
emitFile: false,
|
|
filename: "dist/visualizer.html",
|
|
open: false,
|
|
}),
|
|
//element
|
|
AutoImport({
|
|
resolvers: [ElementPlusResolver()],
|
|
}),
|
|
Components({
|
|
resolvers: [ElementPlusResolver()],
|
|
}),
|
|
],
|
|
optimizeDeps: {
|
|
include: ["qrcode"],
|
|
},
|
|
resolve: {
|
|
// alias: {
|
|
// "@": resolve(__dirname, "src"),
|
|
// },
|
|
alias: {
|
|
"@": _resolve("src"),
|
|
},
|
|
// extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".scss"],
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
// javascriptEnabled: true,
|
|
// additionalData: `
|
|
// @use "@/assets/styles/computed.scss" as *;
|
|
// `,
|
|
|
|
scss: {
|
|
additionalData: '@import "@/assets/styles/computed.scss";',
|
|
},
|
|
// CSS 预处理器
|
|
// preprocessorOptions: {
|
|
// //define global scss variable
|
|
// scss: {
|
|
// javascriptEnabled: true,
|
|
// additionalData: `
|
|
// @use "@/styles/variables.scss" as *;
|
|
// // 必须这样配置才能生效!
|
|
// @use "@/styles/until.scss" as *;
|
|
// `,
|
|
// },
|
|
// },
|
|
},
|
|
},
|
|
server: {
|
|
hmr: true,
|
|
host: "0.0.0.0",
|
|
proxy: {
|
|
"/api": {
|
|
// target: "http://192.168.43.48:8080",
|
|
// 测试地址 gu
|
|
// target: "http://192.168.18.105:8080",
|
|
// target: "http://127.0.0.1:5173",
|
|
target: "http://localhost:18082",
|
|
// 天津地址
|
|
// target:"http://192.168.5.102:18801",
|
|
changeOrigin: true,
|
|
ws: true,
|
|
rewrite: (path: string) => path.replace(new RegExp(`^/api`), ""),
|
|
// only https
|
|
secure: false,
|
|
},
|
|
"/api-svg": {
|
|
// target: "http://127.0.0.1:5173",
|
|
target: "http://localhost:18082",
|
|
// 测试地址 gu
|
|
// target: "http://192.168.18.105:8080",
|
|
// 天津地址
|
|
// target:"http://192.168.5.102:18801",
|
|
changeOrigin: true,
|
|
ws: true,
|
|
rewrite: (path: string) => path.replace(new RegExp(`^/api-svg`), ""),
|
|
// only https
|
|
secure: false,
|
|
},
|
|
"/api_car": {
|
|
// target: "http://127.0.0.1:5173",
|
|
target: "http://localhost:18082",
|
|
// 测试地址 gu
|
|
// target: "http://192.168.18.105:8080",
|
|
// 天津地址
|
|
// target:"http://192.168.5.102:18801",
|
|
changeOrigin: true,
|
|
ws: true,
|
|
rewrite: (path: string) => path.replace(new RegExp(`^/api-svg`), ""),
|
|
// only https
|
|
secure: false,
|
|
},
|
|
// "/ba-api": {
|
|
// target: "http://localhost:8080",
|
|
// // 桐乡地址
|
|
// // target:"http://localhost:8999",
|
|
// // 局域网工作站地址
|
|
// target:"http://127.0.0.1:18082",
|
|
// changeOrigin: true,
|
|
// ws: true,
|
|
// rewrite: (path: string) => path.replace(new RegExp(`^/ba-api`), ""),
|
|
// // only https
|
|
// secure: false,
|
|
// },
|
|
|
|
// "/dd-api": {
|
|
// // target: "http://localhost:8080",
|
|
// // 桐乡地址
|
|
// // target:"http://localhost:8999",
|
|
// // 局域网工作站地址
|
|
// // target:"http://192.168.8.201:14000",
|
|
// target:"http://127.0.0.1:18082",
|
|
// changeOrigin: true,
|
|
// ws: true,
|
|
// rewrite: (path: string) => path.replace(new RegExp(`^/dd-api`), ""),
|
|
// // only https
|
|
// secure: false,
|
|
// }
|
|
},
|
|
},
|
|
});
|