diff --git a/packages/vue-renderer/src/renderers/ssr.js b/packages/vue-renderer/src/renderers/ssr.js index e49115beae..543c1f5c04 100644 --- a/packages/vue-renderer/src/renderers/ssr.js +++ b/packages/vue-renderer/src/renderers/ssr.js @@ -177,7 +177,7 @@ export default class SSRRenderer extends BaseRenderer { const shouldHashCspScriptSrc = csp && (csp.unsafeInlineCompatibility || !containsUnsafeInlineScriptSrc) const inlineScripts = [] - if (renderContext.staticAssetsBase) { + if (shouldInjectScripts && renderContext.staticAssetsBase) { const preloadScripts = [] renderContext.staticAssets = [] const { staticAssetsBase, url, nuxt, staticAssets } = renderContext diff --git a/test/dev/full-static.test.js b/test/dev/full-static.test.js index 18dc3bbb60..b68ed11514 100644 --- a/test/dev/full-static.test.js +++ b/test/dev/full-static.test.js @@ -14,55 +14,76 @@ let builder let server = null let generator = null +const generateAndStartServer = async (overrides) => { + const config = await loadFixture('full-static', { + generate: { + static: false, + dir: '.nuxt-generate' + }, + ...(overrides || {}) + }) + const nuxt = new Nuxt(config) + await nuxt.ready() + + builder = new Builder(nuxt) + builder.build = jest.fn() + generator = new Generator(nuxt, builder) + + await generator.generate() + + const serve = serveStatic(distDir) + server = http.createServer((req, res) => { + serve(req, res, finalhandler(req, res)) + }) + + port = await getPort() + server.listen(port) +} + describe('full-static', () => { - beforeAll(async () => { - const config = await loadFixture('full-static', { - generate: { - static: false, - dir: '.nuxt-generate' - } - }) - const nuxt = new Nuxt(config) - await nuxt.ready() + describe('with scripts', () => { + beforeAll(async () => await generateAndStartServer()) - builder = new Builder(nuxt) - builder.build = jest.fn() - generator = new Generator(nuxt, builder) + test('/payload (custom build.publicPath)', async () => { + const { body: html } = await rp(url('/payload')) - await generator.generate() - - const serve = serveStatic(distDir) - server = http.createServer((req, res) => { - serve(req, res, finalhandler(req, res)) + expect(html).toContain('