60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { templatePreviewCss } from "./template-preview-css.mjs";
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
css: { postcss: { plugins: [templatePreviewCss()] } },
|
|
base: process.env.VITE_APP_BASE_PATH ?? "/",
|
|
resolve: {
|
|
dedupe: ["react", "react-dom"],
|
|
alias: {
|
|
"@tarojs/components": `${process.cwd()}/src/features/brand/taro-web-components.jsx`,
|
|
"@tarojs/taro": `${process.cwd()}/src/features/brand/taro-web-runtime.jsx`,
|
|
},
|
|
},
|
|
define: {
|
|
"process.env": "{}",
|
|
"process.env.TARO_PLATFORM": JSON.stringify("web"),
|
|
"process.env.TARO_ENV": JSON.stringify("h5"),
|
|
PREVIEW_ALL_TEMPLATES: JSON.stringify(true),
|
|
TEMPLATE_MANIFEST: JSON.stringify({ navigation: [] }),
|
|
},
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: Number(process.env.ADMIN_PORT ?? 3000),
|
|
proxy: {
|
|
"/api": {
|
|
target: process.env.VITE_DEV_API_TARGET ?? "http://localhost:3001",
|
|
rewrite: (path) => path.replace(/^\/api/, ""),
|
|
},
|
|
"/media": {
|
|
target: process.env.VITE_MEDIA_API_TARGET ?? "http://localhost:3001",
|
|
changeOrigin: true,
|
|
},
|
|
...(process.env.VITE_MEDIA_PROXY_TARGET
|
|
? {
|
|
[`/${(process.env.OBJECT_STORAGE_BUCKET ?? "personal-brand-media").replace(/^\/+/, "")}`]:
|
|
{
|
|
target: process.env.VITE_MEDIA_PROXY_TARGET,
|
|
changeOrigin: true,
|
|
},
|
|
}
|
|
: {}),
|
|
},
|
|
},
|
|
build: {
|
|
outDir: "dist",
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes("/node_modules/.pnpm/react-dom@")) return "react-runtime";
|
|
if (id.includes("/node_modules/.pnpm/react@")) return "react-runtime";
|
|
if (id.includes("/node_modules/.pnpm/scheduler@")) return "react-runtime";
|
|
return undefined;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|