@lexiang/babel-plugin-component

0.2.7 • Public • Published

Introduction

lazy load component, base on babel-plugin-component

Install

yarn add @lexiang/babel-plugin-component -D

Usage

Via .babelrc or babel-loader.

{
  "plugins": [
    ["@lexiang/babel-plugin-component", options]
  ]
}

options

  • libraryName: module name
  • styleLibraryName: style module name
  • styleLibrary: Import a independent theme package with more config
    styleLibrary: {
      "name": "xxx", // same with styleLibraryName
      "base": true,  // if theme package has a base.css
      "path": "[module]/index.css",  // the style path. e.g. module Alert =>  alert/index.css
      "mixin": true  // if theme-package not found css file, then use [libraryName]'s css file
    }
    
  • style: import css from '[module]/index.css', default false
  • libDir: dist directory, default lib
  • root: main file dir, default index
  • camel2Dash: whether parse name to dash mode or not, default true

Example

convert

import { button } from 'components';

to

var button = require('components/lib/button');

style Example

when it is set to true convert

import { button } from 'components';

to

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

Package Sidebar

Install

npm i @lexiang/babel-plugin-component

Weekly Downloads

110

Version

0.2.7

License

MIT

Unpacked Size

13.9 kB

Total Files

4

Last publish

Collaborators

  • lexiangla
  • cattyhuang