From 9f4d1a39bd6f9a90c8c5f3821cedaf01d7293c42 Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Tue, 14 Dec 2021 06:56:32 +0000 Subject: [PATCH] feat(#357): make $druxt plugin first --- packages/druxt/src/nuxt/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/druxt/src/nuxt/index.js b/packages/druxt/src/nuxt/index.js index 8b6029049..8337e9339 100644 --- a/packages/druxt/src/nuxt/index.js +++ b/packages/druxt/src/nuxt/index.js @@ -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'),