mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(compat): add template variables for compat module (#162)
This commit is contained in:
parent
de22e8f71b
commit
f497020f6e
@ -6,6 +6,7 @@ import { getNitroContext, NitroContext } from './context'
|
||||
import { createDevServer } from './server/dev'
|
||||
import { wpfs } from './utils/wpfs'
|
||||
import { resolveMiddleware } from './server/middleware'
|
||||
import { serializeTemplate } from './utils'
|
||||
|
||||
export default function nuxt2CompatModule () {
|
||||
const { nuxt } = this
|
||||
@ -51,6 +52,15 @@ export default function nuxt2CompatModule () {
|
||||
serverConfig.devtool = false
|
||||
})
|
||||
|
||||
// Add missing template variables (which normally renderer would create)
|
||||
nitroContext._internal.hooks.hook('nitro:template:document', (htmlTemplate) => {
|
||||
if (!htmlTemplate.contents.includes('BODY_SCRIPTS_PREPEND')) {
|
||||
const fullTemplate = ['{{ BODY_SCRIPTS_PREPEND }}', '{{ APP }}', '{{ BODY_SCRIPTS }}'].join('\n ')
|
||||
htmlTemplate.contents = htmlTemplate.contents.replace('{{ APP }}', fullTemplate)
|
||||
htmlTemplate.compiled = 'module.exports = ' + serializeTemplate(htmlTemplate.contents)
|
||||
}
|
||||
})
|
||||
|
||||
// Nitro client plugin
|
||||
this.addPlugin({
|
||||
fileName: 'nitro.client.js',
|
||||
|
Loading…
Reference in New Issue
Block a user