Explorar el Código

perf: 编译脚本优化

BaiLuoYan hace 3 semanas
padre
commit
6508cd4b7e
Se han modificado 2 ficheros con 9 adiciones y 1 borrados
  1. 3 0
      build/compress.ts
  2. 6 1
      vite.config.ts

+ 3 - 0
build/compress.ts

@@ -15,6 +15,8 @@ export const configCompressPlugin = (compress: BuildCompression): Plugin | Plugi
         filter: () => true,
         // 压缩后是否删除原始文件
         deleteOriginFile: false,
+        // 是否打印详细信息
+        verbose: false,
     };
     const br = {
         ext: '.br',
@@ -22,6 +24,7 @@ export const configCompressPlugin = (compress: BuildCompression): Plugin | Plugi
         threshold: 0,
         filter: () => true,
         deleteOriginFile: false,
+        verbose: false,
     };
 
     const codeList = [

+ 6 - 1
vite.config.ts

@@ -92,11 +92,16 @@ export default defineConfig(({ mode }) => {
         build: {
             outDir: 'dist',
             sourcemap: !isProd,
-            // target 由 plugin-legacy 的 targets 控制,不在此设置避免被覆盖并触发警告
+            // 为了处理 brotli-wasm 的引用问题,target 已改为使用 plugin-legacy 的 targets 控制
             // target: ['es2015', 'chrome87', 'safari13', 'firefox78', 'edge88'],
+            // 与 plugin-legacy targets 对齐,使 CSS 压缩/转换兼容同一批浏览器(plugin-legacy 不处理 CSS)
             cssTarget: ['chrome87', 'safari13', 'firefox78', 'edge88'],
             rollupOptions: {
                 output: {
+                    // 产物文件名:入口/代码块用 [name]-[hash:8].js,静态资源用 [name]-[hash:8][extname]
+                    entryFileNames: 'assets/[name]-[hash].js',
+                    chunkFileNames: 'assets/[name]-[hash].js',
+                    assetFileNames: 'assets/[name]-[hash][extname]',
                     manualChunks: {
                         'react-vendor': ['react', 'react-dom', 'react-router-dom'],
                         'antd-vendor': ['antd', '@ant-design/icons'],