开发的时候有这种需求,我们需要自己做自己公司的js/ui组件库,这时我们用rollup来进行组件库的开发
至于放在那里 可以放到npm官方 也可以安装自己的npm仓库
1.关于 babel,typescript,webpack,rollup,前两者是转义工具,单纯的翻译功能,后两者是打包工具
2.之所以react采用rollup而并非webpack,大体上有这么几个文章在说明
https://github.com/nolanlawson/cost-of-small-modules/pull/8
https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c
https://github.com/facebook/react/pull/9327
https://github.com/facebook/react/issues/6351
https://github.com/facebook/react/pull/4230
https://github.com/facebook/react/issues/4927
https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/
3.安装rollup
yarn add rollup --dev
4.新建rollup.config.js
module.exports = {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
}
};
5.新建src/main.js
console.log('hello rollup')
6.更改package.json
...
"scripts": {
"build":"rollup -c"
}
7.打包
npm run build