mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
fix(vue-renderer): respect injectScripts for target:static (#8912)
This commit is contained in:
parent
880fe4abd7
commit
07e97f168a
@ -177,7 +177,7 @@ export default class SSRRenderer extends BaseRenderer {
|
|||||||
const shouldHashCspScriptSrc = csp && (csp.unsafeInlineCompatibility || !containsUnsafeInlineScriptSrc)
|
const shouldHashCspScriptSrc = csp && (csp.unsafeInlineCompatibility || !containsUnsafeInlineScriptSrc)
|
||||||
const inlineScripts = []
|
const inlineScripts = []
|
||||||
|
|
||||||
if (renderContext.staticAssetsBase) {
|
if (shouldInjectScripts && renderContext.staticAssetsBase) {
|
||||||
const preloadScripts = []
|
const preloadScripts = []
|
||||||
renderContext.staticAssets = []
|
renderContext.staticAssets = []
|
||||||
const { staticAssetsBase, url, nuxt, staticAssets } = renderContext
|
const { staticAssetsBase, url, nuxt, staticAssets } = renderContext
|
||||||
|
@ -14,13 +14,13 @@ let builder
|
|||||||
let server = null
|
let server = null
|
||||||
let generator = null
|
let generator = null
|
||||||
|
|
||||||
describe('full-static', () => {
|
const generateAndStartServer = async (overrides) => {
|
||||||
beforeAll(async () => {
|
|
||||||
const config = await loadFixture('full-static', {
|
const config = await loadFixture('full-static', {
|
||||||
generate: {
|
generate: {
|
||||||
static: false,
|
static: false,
|
||||||
dir: '.nuxt-generate'
|
dir: '.nuxt-generate'
|
||||||
}
|
},
|
||||||
|
...(overrides || {})
|
||||||
})
|
})
|
||||||
const nuxt = new Nuxt(config)
|
const nuxt = new Nuxt(config)
|
||||||
await nuxt.ready()
|
await nuxt.ready()
|
||||||
@ -38,7 +38,11 @@ describe('full-static', () => {
|
|||||||
|
|
||||||
port = await getPort()
|
port = await getPort()
|
||||||
server.listen(port)
|
server.listen(port)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
describe('full-static', () => {
|
||||||
|
describe('with scripts', () => {
|
||||||
|
beforeAll(async () => await generateAndStartServer())
|
||||||
|
|
||||||
test('/payload (custom build.publicPath)', async () => {
|
test('/payload (custom build.publicPath)', async () => {
|
||||||
const { body: html } = await rp(url('/payload'))
|
const { body: html } = await rp(url('/payload'))
|
||||||
@ -66,3 +70,20 @@ describe('full-static', () => {
|
|||||||
await server.close()
|
await server.close()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('without scripts', () => {
|
||||||
|
beforeAll(async () => await generateAndStartServer({ render: { injectScripts: false } }))
|
||||||
|
|
||||||
|
test('should not inject scripts', async () => {
|
||||||
|
const { body: html } = await rp(url('/payload'))
|
||||||
|
|
||||||
|
expect(html).not.toContain('<script')
|
||||||
|
expect(html).not.toContain('<link')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Close server and ask nuxt to stop listening to file changes
|
||||||
|
afterAll(async () => {
|
||||||
|
await server.close()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user