56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import path from "path";
|
|
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react-swc";
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
import robots from "./rollup-plugin-robots";
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
envDir: path.resolve(".", "env"),
|
|
plugins: [
|
|
react(),
|
|
robots(),
|
|
visualizer({
|
|
open: true,
|
|
filename: "stats.html",
|
|
}),
|
|
],
|
|
css: {
|
|
modules: {
|
|
localsConvention: "camelCase",
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
react: ["react"],
|
|
"react-dom": ["react-dom"],
|
|
"react-router": ["react-router"],
|
|
http: ["axios", "qs"],
|
|
},
|
|
// 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";
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|