Skip to content

Commit

Permalink
fix: change axios plugin order #116
Browse files Browse the repository at this point in the history
  • Loading branch information
mercs600 committed Jun 17, 2021
1 parent 70e3dd2 commit 49a1dfe
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,35 @@ function Typo3(options) {
options = defu(runtimeConfig, options)
}

const modulesList = [
...this.nuxt.options.modules,
...this.nuxt.options.buildModules
]

if (!modulesList.includes('@nuxtjs/axios')) {
this.requireModule(['@nuxtjs/axios', this.options.axios || options.api])
}

const configFn = this.options.extendPlugins
this.options.extendPlugins = plugins => {
const pluginIndex = plugins.findIndex(({ src }) => src.includes('axios.js'))
const shouldBeFirstPlugin = plugins[pluginIndex]
plugins.splice(pluginIndex, 1)
plugins.unshift(shouldBeFirstPlugin)

if (configFn) {
return configFn(plugins)
}
return plugins
}

// add $typo3pwa context
this.addPlugin({
src: resolve(__dirname, './templates/plugins/context.js'),
options,
fileName: join('typo3', 'plugins.context.js')
})

this.requireModule(['@nuxtjs/axios', this.options.axios || options.api])

// add typo3pwa store
this.addPlugin({
src: resolve(__dirname, './templates/store/index.js'),
Expand Down

0 comments on commit 49a1dfe

Please sign in to comment.