61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
import { defineConfig, loadEnv } from "vite";
|
||
import vue from "@vitejs/plugin-vue";
|
||
import eslintPlugin from "vite-plugin-eslint";
|
||
import DefineOptions from "unplugin-vue-define-options/vite";
|
||
// import AutoImport from "unplugin-auto-import/vite";
|
||
import Components from "unplugin-vue-components/vite";
|
||
import { VantResolver } from "unplugin-vue-components/resolvers";
|
||
import basicSsl from "@vitejs/plugin-basic-ssl";// HTTPS 假证书
|
||
|
||
export default ({ mode }) => {
|
||
return defineConfig({
|
||
base: loadEnv(mode, process.cwd()).VITE_BASE,
|
||
plugins: [
|
||
vue(),
|
||
eslintPlugin(),
|
||
DefineOptions(),
|
||
// AutoImport({
|
||
// resolvers: [],
|
||
// }),
|
||
Components({
|
||
resolvers: [VantResolver()],
|
||
}),
|
||
basicSsl(),// HTTPS 假证书
|
||
],
|
||
server: {
|
||
https: true,// HTTPS 开关
|
||
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]",
|
||
},
|
||
},
|
||
},
|
||
});
|
||
};
|