0.1.1 • Published 8 months ago

unplugin-preset-vue v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

unplugin-preset-vue

NPM version

This is a preset library for Vue's unplugin, which integrates commonly used unplugin libraries such as unplugin-vue, unplugin-auto-import, unplugin-vue-components, etc. You can flexibly enable a specific plugin based on your needs and maintain compatibility with the original configuration of the plugin.

Inspire by: unocss-preset-useful

Install

npm i unplugin-preset-vue
// vite.config.ts
import VuePresets from 'unplugin-preset-vue/vite'

export default defineConfig({
  plugins: [
    VuePresets({ /* options */ }),
  ],
})

Example: playground/

// rollup.config.js
import VuePresets from 'unplugin-preset-vue/rollup'

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

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-preset-vue/webpack')({ /* options */ })
  ]
}

// nuxt.config.js
export default defineNuxtConfig({
  modules: [
    ['unplugin-preset-vue/nuxt', { /* options */ }],
  ],
})

This module works for both Nuxt 2 and Nuxt Vite

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-preset-vue/webpack')({ /* options */ }),
    ],
  },
}

// esbuild.config.js
import { build } from 'esbuild'
import VuePresets from 'unplugin-preset-vue/esbuild'

build({
  plugins: [VuePresets()],
})

Usage

The documents: unplugin-vue

Default options:

const DEFAULT_OPTIONS = {
  imports: ['vue'],
  dts: 'src/auto-imports.d.ts',
  vueTemplate: true,
}

The documents: unplugin-auto-import

Default options:

const DEFAULT_OPTIONS = {
  // allow auto load markdown components under `./src/components/`
  extensions: ['vue', 'md'],
  // allow auto import and register components used in markdown
  include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  dts: 'src/components.d.ts',
}

The documents: unplugin-vue-components

The documents: unplugin-icons