一、rollup

参考:
redux
reach-router
rollup-starter-lib
rollup-starter-app
roller-cli
create-react-library





一、安装 npm install
--global rollup 二、命令: rollup -c 默认指向rollup.config.js import babel from 'rollup-plugin-babel'; import commonjs from 'rollup-plugin-commonjs'; import peerDepsExternal from 'rollup-plugin-peer-deps-external'; import postcss from 'rollup-plugin-postcss'; import resolve from 'rollup-plugin-node-resolve'; import image from 'rollup-plugin-image'; import sizes from 'rollup-plugin-sizes'; // import env from 'rollup-plugin-env'; // import uglify from 'rollup-plugin-uglify'; import pkg from './package.json'; const external = Object.keys(pkg.dependencies || {}); export default { input: 'src/index.js', output: [ { file: pkg.main, format: 'cjs', }, { file: pkg.module, format: 'es', sourcemap: true, }, ], plugins: [ // env({ NODE_ENV: 'production' }), peerDepsExternal(), postcss({ modules: true, }), image(), babel({ exclude: 'node_modules/**', }), resolve(), commonjs({ include: 'node_modules/**', namedExports: { 'node_modules/react/index.js': ['Component', 'PureComponent', 'Children', 'createElement'], }, }), // uglify(), sizes({ details: true }), ], external, // dependencies 内 不需要打包进去,运行时加载 }; 三、 rollyup 默认将相对路径加载, 如果想加载node_module 需要用rollup-plugin-node-resolve. Rollup will only resolve relative module IDs by default. If you do want to include the module in your bundle, you need to tell Rollup how to find it. In most cases, this is a question of using rollup-plugin-node-resolve. 四 Since most packages in your node_modules folder are probably legacy CommonJS rather than JavaScript modules, you may need to use rollup-plugin-commonjs: 五、 rollup-plugin-babel 在Babel实际编译代码之前,需要进行配置。 创建一个新文件src/.babelrc:

 

转载于:https://www.cnblogs.com/shangyueyue/p/10615135.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值