Skip to content

AaronBank/babel-plugin-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-library

babel-plugin-library

tool-libraries load babel plugin on demand

Installation

npm install babel-plugin-library --save-dev

Use

Method 1:Configure in .babelrc

  • .babelrc
{
  "plugins": [
    [
      "babel-plugin-library",
      {"libraryName": "tool-libraries"}
    ]
  ]
}

webpack

module: {
  rules: [{
    test: /\.js$/,
    loader: "babel-loader",
  }]
}

Method 2:Configure directly in webpack

module.exports = {
  ...
  module: {
    rules: [{
      test: /\.js$/,
      loader: "babel-loader",
      options: {
        plugins: [
          [
            "babel-plugin-library",
            {"libraryName": "tool-libraries"}
          ]
        ]
      }
    }]
  }
  ...
}

Conversion

// Before conversion =>
import { types } from 'tool-libraries'

// After conversion =>
import equal from 'tool-libraries/lib/types'

Licence

MIT

About

tool-library 按需加载 babel插件

Resources

License

Stars

Watchers

Forks

Packages