mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-24 03:42:16 +00:00
20 lines
480 B
JavaScript
20 lines
480 B
JavaScript
|
import { minify } from 'terser';
|
||
|
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
||
|
|
||
|
for (const file of readdirSync('dist/assets')) {
|
||
|
if (!/\.(mjs|js)$/.test(file)) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
console.log(`minifying ${file}...`);
|
||
|
const isModule = /\.mjs$/.test(file);
|
||
|
|
||
|
const output = await minify(readFileSync(`dist/assets/${file}`, 'utf-8'), {
|
||
|
compress: true,
|
||
|
mangle: true,
|
||
|
module: isModule,
|
||
|
});
|
||
|
|
||
|
writeFileSync(`dist/assets/${file}`, output.code);
|
||
|
}
|