chore: add CI workflow and update dependencies in package.json and vite.config.ts

This commit is contained in:
hamster1963
2026-04-02 17:17:16 +08:00
parent e4ba96ea76
commit f7662d2751
4 changed files with 480 additions and 796 deletions
+25 -10
View File
@@ -1,7 +1,7 @@
import { execSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import react from "@vitejs/plugin-react-swc";
import react from '@vitejs/plugin-react'
import { defineConfig } from "vite";
// Get git commit hash
@@ -14,6 +14,22 @@ const getGitHash = () => {
}
};
const getVendorChunkName = (moduleId: string) => {
const normalizedId = moduleId.replace(/\\/g, "/");
if (!normalizedId.includes("/node_modules/")) {
return null;
}
const packagePath = normalizedId.split("/node_modules/").pop();
if (!packagePath) {
return null;
}
const packageName = packagePath.split("/")[0];
return packageName || null;
};
// https://vite.dev/config/
export default defineConfig({
base: "/",
@@ -48,19 +64,18 @@ export default defineConfig({
},
},
build: {
rollupOptions: {
rolldownOptions: {
output: {
entryFileNames: `assets/[name].[hash].js`,
chunkFileNames: `assets/[name].[hash].js`,
assetFileNames: `assets/[name].[hash].[ext]`,
manualChunks(id) {
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
codeSplitting: {
groups: [
{
name: getVendorChunkName,
test: /[\\/]node_modules[\\/]/,
},
],
},
},
},