axios-miniprogram/scripts/build.ts

35 lines
776 B
TypeScript
Raw Permalink Normal View History

2023-05-05 10:59:37 +08:00
import minimist from 'minimist';
import consola from 'consola';
2023-04-28 15:35:54 +08:00
2023-05-05 10:59:37 +08:00
import { distPath, exec } from './utils';
import { checkSize } from './checkSize';
import { safeExit } from './utils';
2023-03-23 20:09:00 +08:00
2023-05-05 10:59:37 +08:00
const args = minimist(process.argv.slice(2));
const watch = Boolean(args.watch || args.w);
const all = Boolean(args.all || args.a);
const sourceMap = all || Boolean(args.sourceMap || args.s);
const dts = all || Boolean(args.dts || args.d);
2023-03-23 20:09:00 +08:00
2023-05-05 10:59:37 +08:00
main();
2023-03-23 20:09:00 +08:00
2023-03-28 21:53:26 +08:00
function main() {
2023-05-05 10:59:37 +08:00
exec('rimraf dist');
2023-05-04 10:39:52 +08:00
2023-05-05 10:59:37 +08:00
consola.info('Rollup');
2023-05-04 10:39:52 +08:00
2023-05-05 10:59:37 +08:00
safeExit(() => {
exec(
`rollup -c rollup.config.ts --configPlugin typescript ${
watch ? '-w' : ''
} --environment SOURCE_MAP:${sourceMap},DTS:${dts}`,
);
});
2023-05-04 10:39:52 +08:00
2023-05-05 10:59:37 +08:00
if (!watch) {
checkSize(`${distPath}/**.js`);
}
2023-05-04 10:39:52 +08:00
2023-05-05 10:59:37 +08:00
console.info('\n');
2023-03-23 20:09:00 +08:00
}