Files
pj_h5_cloud/vite.config.ts
T
2025-01-06 19:09:03 +08:00

56 lines
1.2 KiB
TypeScript

import path from "path";
import { defineConfig, loadEnv } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import Unocss from "unocss/vite";
import { useRouter } from "./src/sheep";
import { filePath } from "./src/sheep/utils/file-path";
export default defineConfig(({ mode }) => {
const {
NODE_ENV,
VITE_APP_DEV_SERVICE,
VITE_APP_PROD_SERVICE,
VITE_IMAGE_BASE_PATH,
} = loadEnv(mode, process.cwd(), "");
const baseUrl =
NODE_ENV == "development" ? VITE_APP_DEV_SERVICE : VITE_APP_PROD_SERVICE;
return {
build: {
target: "es6",
},
plugins: [
uni(),
Unocss(),
{
...useRouter({
pagesJsonDir: path.resolve(__dirname, "./src/pages.json"),
includes: ["meta"],
}),
enforce: "post",
},
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@@": path.resolve(__dirname, "./src/sheep"),
},
},
server: {
host: "0.0.0.0",
port: 8888,
hmr: true,
proxy: {
"/api": {
target: baseUrl,
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
define: {},
};
});