0.0.2 β’ Published 3 years ago
unplugin-cz-v3 v0.0.2
unplugin-cz-v3
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 = booleandefault: 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 = stringdefault: '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/*
/esfor ES Module/libfor 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.