mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-25 06:46:59 +00:00
- Changed the asset directory in Vite configuration to 'um-react.assets' for better organization. - Updated the minification script to read from and write to the new asset directory, ensuring consistency in asset handling.
22 lines
521 B
JavaScript
22 lines
521 B
JavaScript
import { minify } from 'terser';
|
|
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
|
|
|
const assetsDir = 'dist/um-react.assets';
|
|
|
|
for (const file of readdirSync(assetsDir)) {
|
|
if (!/\.(mjs|js)$/.test(file)) {
|
|
continue;
|
|
}
|
|
|
|
console.log(`minifying ${file}...`);
|
|
const isModule = /\.mjs$/.test(file);
|
|
|
|
const output = await minify(readFileSync(`${assetsDir}/${file}`, 'utf-8'), {
|
|
compress: true,
|
|
mangle: true,
|
|
module: isModule,
|
|
});
|
|
|
|
writeFileSync(`${assetsDir}/${file}`, output.code);
|
|
}
|