Skip to content
Module to register global components for Nuxt.js
JavaScript Vue
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci first commit Oct 1, 2019
lib feat: multiple dirs (#13) Jan 23, 2020
test feat: multiple dirs (#13) Jan 23, 2020
.editorconfig first commit Oct 1, 2019
.eslintignore first commit Oct 1, 2019
.eslintrc.js first commit Oct 1, 2019
.gitignore first commit Oct 1, 2019
CHANGELOG.md chore(release): 0.5.0 Jan 23, 2020
LICENSE first commit Oct 1, 2019
README.md feat: multiple dirs (#13) Jan 23, 2020
commitlint.config.js first commit Oct 1, 2019
husky.config.js first commit Oct 1, 2019
jest.config.js first commit Oct 1, 2019
package.json chore(release): 0.5.0 Jan 23, 2020
renovate.json first commit Oct 1, 2019
yarn.lock feat: watch components directory and rebuild (#6) Jan 13, 2020

README.md

@nuxtjs/global-components

npm version npm downloads Circle CI Codecov License

Module to register global components for Nuxt.js

📖 Release Notes

Usage

Suffix your components with .global.{ext} to declare your global components.

components/
  my-component.vue # local component, import it to use it
  my-button.global.vue # global component, no need to register it!

See live demo.

Setup

  1. Add @nuxtjs/global-components dependency to your project
yarn add --dev @nuxtjs/global-components # or npm install --save-dev @nuxtjs/global-components
  1. Add @nuxtjs/global-components to the buildModules section of nuxt.config.js
export default {
  buildModules: [
    // Simple usage
    '@nuxtjs/global-components',

    // With options
    ['@nuxtjs/global-components', { /* module options */ }]
  ]
}

⚠️ If you are using Nuxt < v2.9 you have to install the module as a dependency (No --dev or --save-dev flags) and use modules section in nuxt.config.js instead of buildModules.

Using top level options

export default {
  buildModules: [
    '@nuxtjs/global-components'
  ],
  globalComponents: {
    /* module options */
  }
}

Options

dir

  • Type: String|Array
  • Default: components

A list of directories to find components inside your nuxt project.

suffixes

  • Type: Array
  • Default: ['global']

The suffixes that files can contain.

extensions

  • Type: Array
  • Default: ['vue', 'js', 'ts']

The extensions that files can contain.

ignore

  • Type: Array
  • Default: []

An array of glob patterns to exclude matches.

ignoreNameDetection

  • Type: Boolean
  • Default: false

Ignore name detection using prototype names.

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Insipired by nuxtjs.org

Copyright (c) Nuxt Community

You can’t perform that action at this time.