Skip to content

rhymedys/LightBabelPluginImport

 
 

Repository files navigation

babel-plugin-import

一个轻量的按需加载库

NPM version


Install

npm install light-babel-import --save-dev

Example

Converts

import { _isUrl } from 'light-utils'

to

var _isUrl = require('light-utils/lib/_isUrl')

styleLibraryName Example

Converts

import Components from 'components'
import { Button } from 'components'

to

require('components/lib/styleLibraryName/index.css')
var button = require('components/lib/styleLibraryName/button.css')

Usage

Via .babelrc or babel-loader.

{
  "plugins": [["light-babel-import", options]]
}

Multiple Module

{
  "plugins": [xxx,
    ["light-babel-import", {
      libraryName: "antd",
      style: true,
    }, "antd"],
    ["light-babel-import", {
      libraryName: "test-module",
      style: true,
    }, "test-module"]
  ]
}

About

Modularly import plugin for babel.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.3%
  • Shell 4.7%
  • Makefile 1.0%