Skip to content

Commit

Permalink
feat(#357): make $druxt plugin first
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Dec 14, 2021
1 parent 3289432 commit 9f4d1a3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/druxt/src/nuxt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ const DruxtNuxtModule = function (moduleOptions = {}) {
options
})

// Make the $druxt plugin the first to load.
const extendPlugins = this.options.extendPlugins
this.options.extendPlugins = (plugins) => {
// Run the user defined extendPlugins function if defined.
plugins = typeof extendPlugins === 'function' ? extendPlugins(plugins) : plugins

// Find the $druxt plugin.
const index = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`)
const plugin = plugins[index]

// Move the $druxt plugin to first place.
plugins.splice(index, 1)
plugins.unshift(plugin)

return plugins
}

// Add Vuex plugin.
this.addPlugin({
src: resolve(__dirname, '../templates/store.js'),
Expand Down

0 comments on commit 9f4d1a3

Please sign in to comment.