Rollup 是一個(gè) JavaScript 模塊打包器昔驱,可以將小塊代碼編譯成大塊復(fù)雜的代碼疹尾,例如 library 或應(yīng)用程序。
一骤肛、全局安裝
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', [])
];
三、構(gòu)建
在package.json中加入腳本命令
"scripts": {
"test": "nyc --require esm tape test/test-*.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"build": "rollup -c"
}
四腋颠、監(jiān)聽變化
"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"
},