0.8.1 • Published 8 months ago

unplugin-ca-plus v0.8.1

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

unplugin-ca-plus

Features
  • 💚 On-demand import style for Ca Plus.
  • 🌎 Replace default locale.
  • ⚡️ Supports Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by unplugin.

Installation

npm i unplugin-ca-plus -D
// vite.config.ts
import CaPlus from 'unplugin-ca-plus/vite'

export default {
  plugins: [
    CaPlus({
      // options
    }),
  ],
}

// rollup.config.js
import CaPlus from 'unplugin-ca-plus/rollup'

export default {
  plugins: [
    CaPlus({
      // options
    }),
  ],
}

// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [
    require('unplugin-ca-plus/esbuild')({
      // options
    }),
  ],
})

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-ca-plus/webpack')({
      // options
    }),
  ],
}

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-ca-plus/webpack')({
        // options
      }),
    ],
  },
}

Usage

It will automatically transform:

import { CaButton } from 'ca-plus'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CaButton } from 'ca-plus'
import 'ca-plus/es/components/button/style/css'

Options

useSource

type UseSource = boolean

default: false

// useSource: false
import { CaButton } from 'ca-plus'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CaButton } from 'ca-plus'
import 'ca-plus/es/components/button/style/css'

// useSource: true
import { CaButton } from 'ca-plus'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CaButton } from 'ca-plus'
import 'ca-plus/es/components/button/style/index'

lib

Normally you wouldn't use this option but as a general option we exposed it anyway. When using this your bundle structure should be the same as CaPlus. See unpkg.com for more information.

type Lib = string

default: 'ca-plus'

// lib: 'other-lib'
import { CaButton } from 'other-lib'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CaButton } from 'other-lib'
import 'other-lib/es/components/button/style/css'

format

type Format = 'esm' | 'cjs'

default: 'esm'

esm for ca-plus/es/components/*

cjs for ca-plus/lib/components/*

  • /es for ES Module
  • /lib for CommonJS

This option is for which format to use

// format: 'cjs'
import { CaButton } from 'ca-plus'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CaButton } from 'ca-plus'
import 'ca-plus/lib/components/button/style/css'

prefix

type Prefix = string
// prefix = Al
import { AlButton } from 'xx-lib'

ignoreComponents

type IgnoreComponents = string[]

Skip style imports for a list of components. Useful for Ca Plus components which do not have a style file. At the time of writing, this is only the AutoResizer component.

// format: 'cjs'
import { CaAutoResizer } from 'ca-plus'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CaAutoResizer } from 'ca-plus'

defaultLocale

Replace default locale, you can find locale list here.

Alternate