Skip to content

Commit

Permalink
fix: 不分割js代码,有缓存的情况下性能更好
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Oct 12, 2023
1 parent 19455b0 commit fa499c1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,22 @@ export default defineConfig({
chunkFileNames: "chunks/chunk.[name].js",
entryFileNames: "entry.[name].js",
assetFileNames: "assets/[name].[ext]",
manualChunks(id) {
if (id.includes("node_modules")) {
let arr = id.toString().split("node_modules/")[1].split("/")
// pnpm单独处理
if (id.includes(".pnpm")) {
arr = id.toString().split(".pnpm/")[1].split("/")
}
const dep = arr[0].split("@")[0].replace(/\./g, "-")
// console.log("id=>", id)
// console.log("dep=>", dep)
if (dep !== "") {
return "vendor_" + dep
}
return "vendor"
}
},
// manualChunks(id) {
// if (id.includes("node_modules")) {
// let arr = id.toString().split("node_modules/")[1].split("/")
// // pnpm单独处理
// if (id.includes(".pnpm")) {
// arr = id.toString().split(".pnpm/")[1].split("/")
// }
// const dep = arr[0].split("@")[0].replace(/\./g, "-")
// // console.log("id=>", id)
// // console.log("dep=>", dep)
// if (dep !== "") {
// return "vendor_" + dep
// }
// return "vendor"
// }
// },
},
},
},
Expand Down

0 comments on commit fa499c1

Please sign in to comment.