Rollup 是一个 JavaScript 模块打包器,可以将小块代码编译成大块复杂的代码,例如 library 或应用程序。
一、全局安装
npm i rollup -g
二、使用配置rollup.config.js
const config = (file, plugins) => ({
input: 'src/main.js',
output: {
name: 'test',
format: 'amd',
indent: false,
file
},
plugins
});
export default [
config('test-dev.js', [])
];
三、构建
在package.json中加入脚本命令
"scripts": {
"test": "nyc --require esm tape test/test-*.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"build": "rollup -c"
}
四、监听变化
"main": "index.js",
"scripts": {
"test": "nyc --require esm tape test/test-*.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"build": "rollup -c",
"watch": "rollup -cw"
},