Skip to content

Commit 67c60d1

Browse files
build: modify config to reduce size
1 parent 7446ea7 commit 67c60d1

1 file changed

Lines changed: 6 additions & 23 deletions

File tree

vite.config.ts

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import react from "@vitejs/plugin-react-swc";
22
import { config } from "dotenv";
3-
import path, { resolve } from "path";
3+
import { resolve } from "path";
44
import { defineConfig } from "vite";
55

66
import checkLocalesForMissingKeys from "./src/utils/checkLocalesForMissingKeys";
@@ -47,27 +47,10 @@ export default function build() {
4747
return `src/pages/${chunk.name}/index.js`;
4848
},
4949
manualChunks: (id) => {
50-
if (id.includes("node_modules/monaco-editor")) {
51-
const parts = id.split(path.posix.sep || path.sep);
52-
const vsIndex = parts.findIndex((part) => part === "vs");
53-
if (vsIndex >= 0 && parts.length > vsIndex + 1) {
54-
const { [vsIndex + 2]: folder } = parts;
55-
switch (folder) {
56-
case "browser":
57-
return "monaco-editor-browser";
58-
case "common":
59-
return "monaco-editor-common";
60-
case "contrib":
61-
return "monaco-editor-contrib";
62-
case "standalone":
63-
return "monaco-editor-standalone";
64-
default:
65-
return "monaco-editor-other";
66-
}
67-
}
68-
return "monaco-editor-other";
50+
if (id.includes("node_modules")) {
51+
const [module] = id.split("node_modules/")[1].split("/");
52+
return module.split("/")[0];
6953
}
70-
if (id.includes("node_modules")) return "vendor";
7154
}
7255
},
7356
treeshake: {
@@ -81,8 +64,8 @@ export default function build() {
8164
},
8265
esbuild: {
8366
keepNames: true,
84-
minifyIdentifiers: false,
85-
minifySyntax: false,
67+
minifyIdentifiers: true,
68+
minifySyntax: true,
8669
minifyWhitespace: true
8770
},
8871
plugins: [replaceDevModeConst(), bundleWorker(), react(), makeManifest(), buildContentScript(), copyPublic(), copyBuild(), makeReleaseZips()],

0 commit comments

Comments
 (0)