unplugin-element-plus
Import Element Plus on demand. Support Vite, Webpack, Vue CLI, Rollup and esbuild.
Last updated 4 months ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install unplugin-element-plus 
SYNC missed versions from official npm registry.


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

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


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

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


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

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


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

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


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

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


<summary>Rspack</summary>
// 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

Current Tags

  • 0.11.2                                ...           latest (4 months ago)

25 Versions

  • 0.11.2                                ...           4 months ago
  • 0.11.1                                ...           5 months ago
  • 0.11.0                                ...           5 months ago
  • 0.10.0                                ...           a year ago
  • 0.9.1                                ...           a year ago
  • 0.9.0                                ...           a year ago
  • 0.8.0                                ...           3 years ago
  • 0.7.2                                ...           3 years ago
  • 0.7.1                                ...           3 years ago
  • 0.7.0                                ...           3 years ago
  • 0.6.0                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.4                                ...           4 years ago
  • 0.3.3                                ...           4 years ago
  • 0.3.2                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 12
This Month 38
Last Day 5
Last Week 30
Last Month 117
Dependencies (5)
Dev Dependencies (15)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org | Home |