Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-components

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-components

Components auto importing for Vite

  • 0.2.10
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vite-plugin-components

On demand components auto importing for Vite


Usage

Install

npm i vite-plugin-components -D # yarn add vite-plugin-components -D

Add it to vite.config.js

// vite.config.js
import ViteComponents from 'vite-plugin-components'

export default {
  plugins: [
    ViteComponents()
  ]
}

That's all.

Use components in templates as you would usually do but NO import and component registration required anymore! It will import components on demand, code spliting is also possible.

Basically, it automatically turns this

<template>
  <div>
    <HelloWorld msg="Hello Vue 3.0 + Vite" />
  </div>
</template>

<script>
export default {
  name: 'App'
}
</script>

into this

<template>
  <div>
    <HelloWorld msg="Hello Vue 3.0 + Vite" />
  </div>
</template>

<script>
import HelloWorld from './src/components/HelloWorld.vue'

export default {
  name: 'App',
  components: {
    HelloWorld
  }
}
</script>

Configuration

The following show the default values of the configuration

ViteComponents({
  // Relative paths to the directory to search for components.
  dirs: ['src/components'],
  // Valid file extensions for components.
  extensions: ['vue'],
  // Search for subdirectories
  deep: true,
})

Example

See the Vitesse starter template.

Thanks

Thanks to @brattonross, this project is heavily inspired by vite-plugin-voie.

License

MIT License © 2020 Anthony Fu

FAQs

Package last updated on 26 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc