fix(nitro): use nuxt2 compatible template (#268)

closes #265
This commit is contained in:
Daniel Roe 2021-06-24 12:35:21 +01:00 committed by GitHub
parent 9797642d78
commit c399f142b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 13 deletions

View File

@ -4,9 +4,7 @@
{{ HEAD }}
</head>
<body {{ BODY_ATTRS }}>
{{ BODY_SCRIPTS_PREPEND }}
{{ APP }}
{{ BODY_SCRIPTS }}
<% if (nuxt.options.vite && nuxt.options.dev) { %><script type="module" src="/@vite/client"></script>
<script type="module" src="/entry.mjs"></script><% } %>
</body>

View File

@ -53,14 +53,6 @@ export default function nuxt2CompatModule () {
serverConfig.devtool = false
})
// Add missing template variables (which normally renderer would create)
nitroContext._internal.hooks.hook('nitro: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)
}
})
// Nitro client plugin
this.addPlugin({
fileName: 'nitro.client.js',

View File

@ -121,9 +121,7 @@ function renderHTML (payload, rendered, ssrContext) {
HEAD: meta.headTags +
rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''),
BODY_ATTRS: meta.bodyAttrs,
BODY_SCRIPTS_PREPEND: meta.bodyScriptsPrepend,
APP: _html + state + rendered.renderScripts(),
BODY_SCRIPTS: meta.bodyScripts
APP: meta.bodyScriptsPrepend + _html + state + rendered.renderScripts() + meta.bodyScripts
})
}