Files
stop-shoping-web/vite.config.ts
2026-03-25 14:59:06 +08:00

41 lines
953 B
TypeScript

import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
// https://vite.dev/config/
export default defineConfig({
envDir: path.resolve(".", "env"),
plugins: [react()],
css: {
modules: {
localsConvention: "camelCase",
},
},
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("node_modules")) {
if (id.includes("react")) {
return "react";
} else {
return "vendors";
}
}
return;
},
chunkFileNames: (chunkFileInfo) => {
for (const id of chunkFileInfo.moduleIds) {
const match = id.match(/\/pages\/([^/]+)/);
if (match) {
return `js/${match[1].toLocaleLowerCase()}-[hash].js`;
}
}
return "js/[name]-[hash].js";
},
},
},
},
});