1.0.1 • Published 5 years ago

babel-plugin-library v1.0.1

Weekly downloads
38
License
ISC
Repository
github
Last release
5 years ago

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