|
|
import vue from "@vitejs/plugin-vue";
|
|
|
import path from "path";
|
|
|
import AutoImport from "unplugin-auto-import/vite";
|
|
|
import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
|
|
|
import Components from "unplugin-vue-components/vite";
|
|
|
import { defineConfig } from "vite";
|
|
|
import { prismjsPlugin } from "vite-plugin-prismjs";
|
|
|
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
|
|
|
// 官网:https://vitejs.dev/
|
|
|
// https://vitejs.dev/config/
|
|
|
export default defineConfig({
|
|
|
|
|
|
server: {
|
|
|
port: 8090, // 前端端口
|
|
|
open: true,
|
|
|
proxy: {
|
|
|
"/api": {
|
|
|
target: "http://localhost:5500",
|
|
|
changeOrigin: true,
|
|
|
rewrite: (path) => path.replace(/^\/api/, ""),
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
|
|
|
plugins: [
|
|
|
vue(),
|
|
|
// 自动帮忙导入
|
|
|
AutoImport({
|
|
|
imports: ["vue", "vue-router", "pinia"],
|
|
|
dts: "src/types/auto-imports.d.ts",
|
|
|
}),
|
|
|
Components({
|
|
|
resolvers: [NaiveUiResolver()],
|
|
|
dts: "src/types/components.d.ts",
|
|
|
}),
|
|
|
createSvgIconsPlugin({
|
|
|
// 指定需要缓存的图标文件夹
|
|
|
iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
|
|
|
// 指定symbolId格式
|
|
|
symbolId: "icon-[dir]-[name]",
|
|
|
}),
|
|
|
prismjsPlugin({
|
|
|
languages: [
|
|
|
"java",
|
|
|
"python",
|
|
|
"html",
|
|
|
"css",
|
|
|
"sass",
|
|
|
"less",
|
|
|
"go",
|
|
|
"cpp",
|
|
|
"c",
|
|
|
"js",
|
|
|
"ts",
|
|
|
"sql",
|
|
|
"bash",
|
|
|
"git",
|
|
|
"nginx",
|
|
|
"php",
|
|
|
],
|
|
|
theme: "tomorrow",
|
|
|
css: true,
|
|
|
}),
|
|
|
],
|
|
|
// 解析 设置 resolve
|
|
|
resolve: {
|
|
|
// https://cn.vitejs.dev/config/#resolve-alias
|
|
|
alias: {
|
|
|
// 设置路径
|
|
|
"~": path.resolve(__dirname, "./"),
|
|
|
// 设置别名
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
},
|
|
|
// https://cn.vitejs.dev/config/#resolve-extensions
|
|
|
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
|
|
|
},
|
|
|
|
|
|
|
|
|
});
|