1.0.0 β’ Published 3 years ago
unplugin-dby-element-plus v1.0.0
unplugin-element-plus
This repo is for element-plus related unplugin. Thanks @antfu.
Features
- π On-demand import style for Element Plus.
- π Replace default locale.
- β‘οΈ Supports Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by unplugin.
Installation
npm i unplugin-element-plus -D// vite.config.ts
import ElementPlus from 'unplugin-element-plus/vite'
export default {
plugins: [
ElementPlus({
// options
}),
],
}// rollup.config.js
import ElementPlus from 'unplugin-element-plus/rollup'
export default {
plugins: [
ElementPlus({
// options
}),
],
}// esbuild.config.js
import { build } from 'esbuild'
build({
plugins: [
require('unplugin-element-plus/esbuild')({
// options
}),
],
})// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-element-plus/webpack')({
// options
}),
],
}// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-element-plus/webpack')({
// options
}),
],
},
}Usage
It will automatically transform:
import { ElButton } from 'element-plus'
// β β β β β β
import { ElButton } from 'element-plus'
import 'element-plus/es/components/button/style/css'Options
useSource
type UseSource = booleandefault: false
// useSource: false
import { ElButton } from 'element-plus'
// β β β β β β
import { ElButton } from 'element-plus'
import 'element-plus/es/components/button/style/css'
// useSource: true
import { ElButton } from 'element-plus'
// β β β β β β
import { ElButton } from 'element-plus'
import 'element-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 ElementPlus. See unpkg.com for more information.
type Lib = stringdefault: 'element-plus'
// lib: 'other-lib'
import { ElButton } from 'other-lib'
// β β β β β β
import { ElButton } from 'other-lib'
import 'other-lib/es/components/button/style/css'format
type Format = 'esm' | 'cjs'default: 'esm'
esm for element-plus/es/components/*
cjs for element-plus/lib/components/*
/esfor ES Module/libfor CommonJS
This option is for which format to use
// format: 'cjs'
import { ElButton } from 'element-plus'
// β β β β β β
import { ElButton } from 'element-plus'
import 'element-plus/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
1.0.0
3 years ago