vite

reload优化

预构建

    optimizeDeps: {
      exclude: ["@jhlc/utils", "@jhlc/types", "pdfjs-dist", "echarts", "dayjs"]
    },

生产环境去掉console log和debugger

esbuild: {
  drop: ["debugger"],
  pure: ["console.log"]
}

多入口

vite的入口文件是index.html
设置入口:

build: {
      emptyOutDir: false,
      chunkSizeWarningLimit: 1000,
      minify: false,
      target: ["chrome89", "edge89", "firefox89", "safari15"],
      cssCodeSplit: !pluginOption.isUnionSub,
      rollupOptions: {
        input: {
          main: path.resolve(__dirname, pluginOption.isUnionSub? "public-sub/index.html" : "index.html")
        },
        output: {
          chunkFileNames: `assets/[name].[hash]-${date}.js`,
          entryFileNames: `assets/[name]-${date}.js`,
          assetFileNames: `assets/[name].[hash]-${date}.[ext]`
        }
      },

minify

是否压缩
minify: false, // 不压缩
minify: terser, // 使用terser压缩

posted @ 2024-12-19 09:06  fight139  阅读(14)  评论(0)    收藏  举报