MyGit

element-plus/unplugin-element-plus

Fork: 33 Star: 184 (更新于 1970-01-01 00:00:00)

license: MIT

Language: TypeScript .

🔌 Import Element Plus on demand. Support Vite, Webpack, Vue CLI, Rollup and esbuild.

最后发布版本: v0.8.0 ( 2023-08-03 00:41:09)

官方网址 GitHub网址


unplugin-element-plus

Unit Test

English | 中文

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
// vite.config.ts
import ElementPlus from 'unplugin-element-plus/vite'

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


Rollup
// rollup.config.js
import ElementPlus from 'unplugin-element-plus/rollup'

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


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

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


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


Vue CLI
// 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 = boolean

default: 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 = string

default: '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/*

  • /es for ES Module
  • /lib for 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'

ignoreComponents

type IgnoreComponents = string[]

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

// format: 'cjs'
import { ElAutoResizer } from 'element-plus'

//    ↓ ↓ ↓ ↓ ↓ ↓

import { ElAutoResizer } from 'element-plus'

defaultLocale

Replace default locale, you can find locale list here.

Alternate

最近版本更新:(数据更新于 1970-01-01 00:00:00)

2023-08-03 00:41:09 v0.8.0

2023-07-07 02:38:17 v0.7.2

2023-04-11 17:53:41 v0.7.1

2023-02-17 18:20:51 v0.7.0

2023-02-01 22:12:16 v0.6.0

2023-02-01 14:05:59 v0.5.0

2022-07-01 14:30:46 v0.4.1

2022-04-03 07:58:14 v0.3.4

2022-03-30 02:41:55 v0.3.3

2022-03-13 20:52:59 v0.3.2

主题(topics):

element-plus, esbuild, rollup, unplugin, vite, vue, webpack

element-plus/unplugin-element-plus同语言 TypeScript最近更新仓库

2024-11-22 01:36:46 twentyhq/twenty

2024-11-21 22:40:05 LLOneBot/LLOneBot

2024-11-21 20:34:48 CopilotKit/CopilotKit

2024-11-21 16:58:07 labring/FastGPT

2024-11-21 16:14:54 RSSNext/Follow

2024-11-21 16:12:23 x-extends/vxe-table