美文网首页UFEG-A
rollup工具入门

rollup工具入门

作者: dawn_P | 来源:发表于2018-07-23 16:28 被阅读11次

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"
},

相关文章

网友评论

    本文标题:rollup工具入门

    本文链接:https://www.haomeiwen.com/subject/tuyjmftx.html