0.0.2 β€’ Published 1 year ago

unplugin-cz-v3 v0.0.2

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

unplugin-cz-v3

Unit Test

English | δΈ­ζ–‡

This repo is for cz-v3 related unplugin. Thanks @antfu.

Features
  • πŸ’š On-demand import style for Cz V3.
  • 🌎 Replace default locale.
  • ⚑️ Supports Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by unplugin.

Installation

npm i unplugin-cz-v3 -D
// vite.config.ts
import CzV3 from 'unplugin-cz-v3/vite'

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

// rollup.config.js
import CzV3 from 'unplugin-cz-v3/rollup'

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

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

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

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

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

Usage

It will automatically transform:

import { CzButton } from 'cz-v3'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CzButton } from 'cz-v3'
import 'cz-v3/es/components/button/style/css'

Options

useSource

type UseSource = boolean

default: false

// useSource: false
import { CzButton } from 'cz-v3'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CzButton } from 'cz-v3'
import 'cz-v3/es/components/button/style/css'

// useSource: true
import { CzButton } from 'cz-v3'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CzButton } from 'cz-v3'
import 'cz-v3/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 CzV3. See unpkg.com for more information.

type Lib = string

default: 'cz-v3'

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

//    ↓ ↓ ↓ ↓ ↓ ↓

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

format

type Format = 'esm' | 'cjs'

default: 'esm'

esm for cz-v3/es/components/*

cjs for cz-v3/lib/components/*

  • /es for ES Module
  • /lib for CommonJS

This option is for which format to use

// format: 'cjs'
import { CzButton } from 'cz-v3'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { CzButton } from 'cz-v3'
import 'cz-v3/lib/components/button/style/css'

prefix

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

defaultLocale

Replace default locale, you can find locale list here.

Alternate