rollup.js配置

const rollup = require('rollup');

const config = require('./config.js');
const outputOptions = config.output;


async function build () {
  const bundel = await rollup.rollup(config)

  const { code, map } = await bundel.generate(outputOptions)
  await bundel.write(outputOptions)
}

const watcher = rollup.watch(config);

watcher.on('event', event => {
  console.log('event', event.code);
  build();
  // event.code 会是下面其中一个:
  //   START        — 监听器正在启动(重启)
  //   BUNDLE_START — 构建单个文件束
  //   BUNDLE_END   — 完成文件束构建
  //   END          — 完成所有文件束构建
  //   ERROR        — 构建时遇到错误
  //   FATAL        — 遇到无可修复的错误
});

consfig.js

const rollup = require('rollup');
const json = require('rollup-plugin-json');
const resolve = require('rollup-plugin-node-resolve');
const babel = require('rollup-plugin-babel');
const eslint = require('rollup-plugin-eslint').eslint;

const outputOptions = {
  file: 'dist/echarts.js', // 文件输出目录
  format: 'umd', // 格式,amd(异步模块定义),cjs(commonjs),es(将软件包保存为es模块文件),iife(适合作为
                    
                    

你可能感兴趣的:(rollup.js配置)