@hankliu/babel-react

1.0.1 • Public • Published

HankLiu React Babel

提供基础的 react babel 配置项

安装

npm install @hankliu/babel-react -D

or

yarn add @hankliu/babel-react -D

使用

  • in .babelrc.js
const babelConfig = require('@hankliu/babel-react');
// 修改规则
babelConfig.presets.push('@babel/preset-flow');
// if use antd
babelConfig.plugins.push(['import', { libraryName: 'antd', style: true }]);
babelConfig.plugins.push('@babel/plugin-transform-runtime');
babelConfig.plugins.push('react-hot-loader/babel');
module.exports = babelConfig;
  • in webpack with babel-loader
{
   rules: [{
    test: /\.js(x*)$/,
    loader: require.resolve('babel-loader'),
    options: babelConfig
  }]
}

注意

我们使用的是 peerDependencies 管理依赖,如果是在npm2中使用该插件,不许需要在自己项目中额外安装下列依赖,npm2会自行强制安装peerDependencies所要求指定的依赖包;如果是在npm3+中使用该插件,npm3中不会再要求peerDependencies所指定的依赖包被强制安装,相反npm3会在安装结束后检查本次安装是否正确,如果不正确会给用户打印警告提示。

"peerDependencies": {
  "@babel/core": "^7.x",
  "@babel/plugin-proposal-class-properties": "^7.x",
  "@babel/plugin-proposal-decorators": "^7.x",
  "@babel/plugin-syntax-dynamic-import": "^7.x",
  "@babel/preset-env": "^7.x",
  "@babel/preset-react": "^7.x"
}

Readme

Keywords

Package Sidebar

Install

npm i @hankliu/babel-react

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

3.24 kB

Total Files

4

Last publish

Collaborators

  • hank.liu