Skip to content

Commit

Permalink
🐛 fix(custom): 删除js文件内的map映射
Browse files Browse the repository at this point in the history
  • Loading branch information
master1lan committed Feb 19, 2023
1 parent 96702c4 commit 7d2f1f5
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 120 deletions.
8 changes: 8 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ fileList.forEach((file) => {
const full_name_file = path.join(filePath, file);
if (path.extname(full_name_file) === ".map") {
fs.unlinkSync(full_name_file);
} else if (path.extname(full_name_file) === ".js") {
console.log(full_name_file);
const data = fs.readFileSync(full_name_file, "utf-8");
const result = data.replace(
RegExp(`//# sourceMappingURL=[0-9A-Za-z-]*.js.map`, "g"),
""
);
fs.writeFileSync(full_name_file, result, "utf-8");
}
});

Expand Down
2 changes: 1 addition & 1 deletion config/vite.master.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default mergeConfig(
],
build: {
sourcemap: true,
outDir: addProjectPath("dist"),
outDir: "dist",
emptyOutDir: true,
reportCompressedSize: false,
minify: "esbuild",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "tsc && vite build --config ./config/vite.master.config.ts && node build.js",
"preview": "vite preview",
"commit": "cz",
"build:release": "vite build --config ./config/vite.release.config.ts && node build.js",
"build:release": "vite build --config ./config/vite.release.config.ts && node build.js",
"release:changelog": "standard-version --preset gitmoji-config"
},
"config": {
Expand Down
Loading

0 comments on commit 7d2f1f5

Please sign in to comment.