All Projects → harlan-zw → vue-cli-plugin-import-components

harlan-zw / vue-cli-plugin-import-components

Licence: MIT License
🔌 Automatically import components in your Vue CLI apps.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue-cli-plugin-import-components

design-system
👾 A Design System for the French Health Insurance
Stars: ✭ 28 (-26.32%)
Mutual labels:  components, vue-cli
vue2
【🔥Vue.js资讯📚】目前web前端开发非常火爆的框架;定时更新,欢迎 Star 一下。
Stars: ✭ 415 (+992.11%)
Mutual labels:  vue-cli
bootstrap-vue-3
Early (but lovely) implementation of Vue 3, Bootstrap 5 and Typescript
Stars: ✭ 314 (+726.32%)
Mutual labels:  components
elements
Lovingly crafted ui components based on web components. Works well with all Frameworks - including Angular, React and Vue.
Stars: ✭ 42 (+10.53%)
Mutual labels:  components
vue-multivue
Use multiple Vue apps of the same class on the same page
Stars: ✭ 17 (-55.26%)
Mutual labels:  components
vue-cli-ghpages
Made for vue-cli users. Publish to any gh-pages branch on GitHub. The Single-Page App Hack for GitHub Pages.
Stars: ✭ 25 (-34.21%)
Mutual labels:  vue-cli
el.js
✨ Higher-order elements powered by transclusion.
Stars: ✭ 35 (-7.89%)
Mutual labels:  components
Smart-Inspector
Fluent re-take on Unity Inspector UX. Packed with QoL improvements.
Stars: ✭ 680 (+1689.47%)
Mutual labels:  components
muilessium
UI Framework for simple websites - landings, blogs, etc.
Stars: ✭ 16 (-57.89%)
Mutual labels:  components
foundational-design-system-proto
A prototype for a foundational design system at Shopify
Stars: ✭ 82 (+115.79%)
Mutual labels:  components
xu ui
基于react的轻量级可扩展组件库
Stars: ✭ 78 (+105.26%)
Mutual labels:  components
vue-cli-plugin-dll
Vue CLI 3 plugin for Webpack DllPlugin/DllReferencePlugin
Stars: ✭ 77 (+102.63%)
Mutual labels:  vue-cli
unitscss
UNITS is a simple and beautiful CSS component set.
Stars: ✭ 13 (-65.79%)
Mutual labels:  components
styled-mixin
Simple wrapper for creating styled-components mixins
Stars: ✭ 17 (-55.26%)
Mutual labels:  components
ui
🦄 Decentraland UI
Stars: ✭ 145 (+281.58%)
Mutual labels:  components
vue-tutorial
A short, sweet, fast rampup tutorial for Vuejs
Stars: ✭ 27 (-28.95%)
Mutual labels:  vue-cli
4all-ui
Biblioteca de componentes de front-end
Stars: ✭ 11 (-71.05%)
Mutual labels:  components
figma-export
Export tool for Figma. You can easily and automatically export your Figma components and use them directly into your website.
Stars: ✭ 99 (+160.53%)
Mutual labels:  components
oreooo
使用 Vue CLI 重置的奥利奥!
Stars: ✭ 21 (-44.74%)
Mutual labels:  vue-cli
uce-template
A Vue 3 inspired Custom Elements toolless alternative.
Stars: ✭ 96 (+152.63%)
Mutual labels:  components

vue-cli-plugin-import-components

Automatically import components in your Vue CLI app with tree shaking, supporting Vue 2 and 3.

Why and How?

Checkout my article about why this feature exists, how it works and the issues.

ℹ️ Need something more powerful? Consider using unplugin-vue-components

Features

  • 🧙 Vue 2 and 3 support with full tree shaking
  • Lazy load your components
  • 🔥 Hot Module Reloading ready
  • 📐 Written in Typescript

Setup

Install using Vue CLI. (Vue CLI 4+ is recommended)

vue add import-components

Usage

Add components to your components/ folder.

| components/
---| ComponentFoo.vue
---| ComponentBar.vue

Use them in any .vue as you would normally. Access your components with either PascalCase or kebab-case.

<template>
<div>
  <ComponentFoo />
  <component-bar />
</div>
</template>

Remove imports and components from the script section.

Async Component Loading

You can load your components async by prefixing your component name with Lazy or lazy-, depending on your syntax.

<template>
<div>
  <!-- ComponentFoo will be loaded in async -->
  <LazyComponentFoo />
  <!-- ComponentBar will be loaded sync -->
  <ComponentBar />
</div>
</template>

Configuration

You can change the behaviour of the plugin by modifying the options in ./vue.config.js.

// vue.config.js
module.exports = {
  pluginOptions: {
    components: {
      ...
    }
  }
}

Options

All options are optional.

path - String

The path used for scanning to find components. Note: It should be relative to your project root.

Default: ./src/components

pattern - String

Regex to find the files within the path. Note: If you omit the pattern it will use the configured extensions

Default: **/*.{${extensions.join(',')},}

ignore - String[]

Regex to ignore files within the path.

Default: [ '**/*.stories.js' ],

mapComponent - (component : Component) => Component | false

A function which you can use to filter out paths you don't want to be scanned.

For example, if we wanted to access your automatically components only when they're prefixed them with auto, you could use the below code.

// vue.config.js
module.exports = {
  pluginOptions: {
    components: {
      // prefix all automatically imported components with an auto prefix
      mapComponent (component) {
        component.pascalCase = 'Auto' + upperFirst(component.pascalCase)
        component.kebabName = 'auto-' + component.pascalCase
        return component
      }
    }
  }
}

extensions - String[]

When scanning the path for components, which files should be considered components.

Default: ['.js', '.vue', '.ts']

Limitations

Static Imports Only

Only components that are statically defined within your template will work.

<template>
  <component :is="dynamicComponent"/>
</template>

Using folders as namespaces

It is assumed you are using the Vue conventions for naming your components. The below would not work without manually mapping the components.

| components/
---| Foo.vue
------| Namespace/Foo.vue

It would create a conflict with two components called Foo.vue. You should name your component files with the namespace. i.e NamespaceFoo.vue.

Javascript Components

You may need to refresh your browser when you are updating them. The hot module reloading seems to be a little buggy sometimes.

It's recommended that you stick with .vue SFC components.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].