GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - element-plus/unplugin-element-plus: πŸ”Œ Import Element Plus on demand. Support Vite, Webpack, Vue CLI, Rollup and esbuild.

BranchesTags
Open more actions menu

Latest commit

 

History

341 Commits
341 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
examples
examples
 
 
src
src
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README.zh-CN.md
README.zh-CN.md
 
 
eslint.config.js
eslint.config.js
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 
tsconfig.json
tsconfig.json
 
 
tsdown.config.ts
tsdown.config.ts
 
 

Repository files navigation


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
    }),
  ],
}


Rolldown
// rolldown.config.js
import ElementPlus from 'unplugin-element-plus/rolldown'

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


esbuild
// esbuild.config.js
import { build } from 'esbuild'
import ElementPlus from 'unplugin-element-plus/esbuild'

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


Webpack
// webpack.config.js
import ElementPlus from 'unplugin-element-plus/webpack'

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


Rspack
// rspack.config.js
import ElementPlus from 'unplugin-element-plus/rspack'
export default {
  /* ... */
  plugins: [
    ElementPlus({
      // 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

  • unplugin-vue-components

About

πŸ”Œ Import Element Plus on demand. Support Vite, Webpack, Vue CLI, Rollup and esbuild.

unplugin.element-plus.org

Topics

element-plusesbuildrolluprspackunpluginvitevuewebpack

Resources

Readme
MIT license
Activity
Custom properties

Stars

252 stars

Watchers

7 watching

Forks

40 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.