kopia lustrzana https://github.com/cheeaun/phanpy
Test remove sourcemaps for icons & locale files
- Icons are images, just that they're wrapped inside JS. - Locales point to PO files There's not much benefit in generating sourcemaps for thempull/1096/merge
rodzic
cd3a60110c
commit
0187fb38ac
|
@ -237,6 +237,29 @@ export default defineConfig({
|
|||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'remove-chunk-sourcemaps',
|
||||
generateBundle(_, bundle) {
|
||||
// Remove .js.map files and sourcemap references for specific chunks
|
||||
Object.keys(bundle).forEach((fileName) => {
|
||||
const shouldRemoveSourcemap =
|
||||
fileName.includes('locales/') || fileName.includes('icons/');
|
||||
|
||||
if (fileName.endsWith('.js.map') && shouldRemoveSourcemap) {
|
||||
delete bundle[fileName];
|
||||
} else if (fileName.endsWith('.js') && shouldRemoveSourcemap) {
|
||||
const chunk = bundle[fileName];
|
||||
if (chunk.type === 'chunk' && chunk.code) {
|
||||
// Remove sourceMappingURL comment
|
||||
chunk.code = chunk.code.replace(
|
||||
/\/\/# sourceMappingURL=.+\.js\.map\n?$/,
|
||||
'',
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
Ładowanie…
Reference in New Issue