babel-plugin-import-demand

0.1.5 • Public • Published

babel-plugin-import-demand

NPM version NPM downloads

Example

Converts

import { Button, DatePicker } from 'projectName';

(roughly) to

var _button = require('projectName/lib/button');
 
var _button2 = _interopRequireDefault(_button);
 
require('projectName/lib/button/style/css');
 
var _date_picker = require('projectName/lib/date-picker');
 
var _date_picker2 = _interopRequireDefault(_date_picker);
 
require('projectName/lib/date-picker/style/css');

Usage

npm install babel-plugin-import-demand --save-dev

Via .babelrc or babel-loader.

{
  "plugins": [["import-demand", options]]
}

options

options can be object.

For Example:

{
  "libName": "antd",
  "libPath": "lib",        // default: lib
  "spell": true,           // default: false
  "cssPath": "style/css",  // default: undefined
}

options can be an array.

For Example:

[
  {
    "libName": "project",
    "libPath": "dist",       // default: lib
  },
  {
    "libName": "antd",
    "libPath": "lib",
    "spell": true,
    "cssPath": "style"
  }
]

Note

babel-plugin-import-demand will be not working if you add the library in webpack config vender

Package Sidebar

Install

npm i babel-plugin-import-demand

Weekly Downloads

9

Version

0.1.5

License

MIT

Last publish

Collaborators

  • jindada