build.js 730 Bytes
import terser from '@rollup/plugin-terser';
// 进行统一打包管理 rollup
import { rollup } from 'rollup';

import { clearDist, getRollupConfigs } from './buildBase.js';

async function build() {
  const configs = await getRollupConfigs();
  for (const name of Object.keys(configs)) {
    clearDist(name);
    const config = configs[name];
    console.log(`正在打包:${name}`);
    const bundle = await rollup({
      input: config.input,
      plugins: [...config.plugins, terser()],
      external: config.external,
    });
    const tasks = [];
    for (const output of config.output) {
      tasks.push(bundle.write(output));
    }
    await Promise.all(tasks);
    console.log(`打包完成:${name}`);
  }
}
build();