84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
import { defineConfig, loadEnv } from "vite";
|
||
import vue from "@vitejs/plugin-vue";
|
||
import eslintPlugin from "vite-plugin-eslint";
|
||
import Components from "unplugin-vue-components/vite";
|
||
import { VantResolver } from "unplugin-vue-components/resolvers";
|
||
import EnhanceLog from "vite-plugin-enhance-log";
|
||
// import removeConsole from "vite-plugin-remove-console";
|
||
|
||
export default ({ mode }) => {
|
||
return defineConfig({
|
||
base: loadEnv(mode, process.cwd()).VITE_BASE,
|
||
plugins: [
|
||
vue(),
|
||
eslintPlugin(),
|
||
Components({
|
||
resolvers: [VantResolver()],
|
||
}),
|
||
// removeConsole({
|
||
// includes: [
|
||
// "assert",
|
||
// "clear",
|
||
// "count",
|
||
// "countReset",
|
||
// "createTask",
|
||
// "debug",
|
||
// "dir",
|
||
// "dirxml",
|
||
// "error",
|
||
// "group",
|
||
// "groupCollapsed",
|
||
// "groupEnd",
|
||
// "info",
|
||
// "log",
|
||
// "profile",
|
||
// "profileEnd",
|
||
// "table",
|
||
// "time",
|
||
// "timeEnd",
|
||
// "timeLog",
|
||
// "timeStamp",
|
||
// "trace",
|
||
// "warn",
|
||
// ],
|
||
// }),
|
||
EnhanceLog({
|
||
preTip: "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀",
|
||
}),
|
||
],
|
||
server: {
|
||
host: true, // 本机的局域网IP,不然其他人无法通过IP访问到,0.0.0.0或true会自动获取本机的IP
|
||
port: 8099, // 端口号
|
||
open: true, // 是否自动打开浏览器
|
||
proxy: {
|
||
[loadEnv(mode, process.cwd()).VITE_PROXY]: {
|
||
target: loadEnv(mode, process.cwd()).VITE_BASE_URL,
|
||
changeOrigin: true,
|
||
ws: true,
|
||
rewrite: (path) => path.replace(/^\/api/, ""),
|
||
},
|
||
},
|
||
},
|
||
resolve: {
|
||
alias: {
|
||
"@": "/src", // 别名,@代表src目录
|
||
},
|
||
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"], // 引入文件时哪些后缀名可以不写
|
||
},
|
||
build: {
|
||
rollupOptions: {
|
||
// 打包多个入口文件
|
||
// input: {
|
||
// admin: path.resolve(__dirname, "index.html"),
|
||
// 其它入口文件路径需要为src/views/*/index.html
|
||
// },
|
||
output: {
|
||
chunkFileNames: "static/js/[name]-[hash].js",
|
||
entryFileNames: "static/js/[name]-[hash].js",
|
||
assetFileNames: "static/[ext]/name-[hash].[ext]",
|
||
},
|
||
},
|
||
},
|
||
});
|
||
};
|