Skip to content

Pushes Nuxt.js plugins to the end of the list instead of the start.

License

Notifications You must be signed in to change notification settings

dword-design/nuxt-push-plugins

Repository files navigation

nuxt-push-plugins

npm version Linux macOS Windows compatible Build status Coverage status Dependency status Renovate enabled
Open in Gitpod Buy Me a Coffee PayPal Patreon

Pushes Nuxt.js plugins to the end of the list instead of the start.

When calling this.addPlugin inside a Nuxt module, Nuxt does in fact not add the plugin to the end of the list, but to the beginning via Array.unshift. There are cases where you actually want to push plugins to the end of the list so that they can make use of already-added plugins. This package provides a helper function to do that.

Install

# npm
$ npm install nuxt-push-plugins

# Yarn
$ yarn add nuxt-push-plugins

Usage

Import the function into your Nuxt module and call it by passing this and the plugins you want to add. It behaves like Array.push.

// module.js

import nuxtPushPlugins from 'nuxt-push-plugins'

export default function () {

  // single plugin
  nuxtPushPlugins(this, require.resolve('./plugin'))

  // plugin object
  nuxtPushPlugins(this, {
    src: require.resolve('./plugin'),
    mode: 'client',
  })

  // multiple plugins
  nuxtPushPlugins(this,
    require.resolve('./plugin'),
    { src: require.resolve('./plugin'), mode: 'client' },
  )
}

Contribute

Are you missing something or want to contribute? Feel free to file an issue or a pull request! ⚙️

Support

Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:

Buy Me a Coffee  If you want to send me a one time donation. The coffee is pretty good 😊.
PayPal  Also for one time donations if you like PayPal.
Patreon  Here you can support me regularly, which is great so I can steadily work on projects.

Thanks a lot for your support! ❤️

License

MIT License © Sebastian Landwehr