feat: add $fetch to client

This commit is contained in:
Pooya Parsa 2020-11-20 14:31:14 +01:00
parent d3d3c0a2ea
commit a7d158798c
2 changed files with 8 additions and 2 deletions

View File

@ -2,5 +2,5 @@ import nuxt2 from './module/nuxt2'
export default function () {
const { nuxt } = this
return nuxt2(nuxt)
return nuxt2(nuxt, this)
}

View File

@ -5,7 +5,7 @@ import { getsigmaContext, SigmaContext } from '../context'
import { createDevServer } from '../server'
import wpfs from '../utils/wpfs'
export default function (nuxt) {
export default function (nuxt, moduleContainer) {
// Build in node_modules/.cache/nuxt
const oldBuildDir = nuxt.options.buildDir
nuxt.options.buildDir = resolve(nuxt.options.rootDir, 'node_modules/.cache/nuxt')
@ -33,6 +33,12 @@ export default function (nuxt) {
nuxt.server = createNuxt2DevServer(sigmaDevContext)
}
// $fetch support in client
moduleContainer.addPlugin({
fileName: 'fetch.client.js',
src: resolve(sigmaContext._internal.runtimeDir, 'app/fetch.client.js')
})
// serverMiddleware bridge
// TODO: render:setupMiddleware hook
// TODO: support m.prefix and m.route