diff --git a/src/vite/manifest.ts b/src/vite/manifest.ts index 87a17faf..d1ce9dc2 100644 --- a/src/vite/manifest.ts +++ b/src/vite/manifest.ts @@ -95,8 +95,8 @@ export async function generateBuildManifest (ctx: ViteBuildContext) { 'var appConfig = window && window.__NUXT__ && window.__NUXT__.config.app || {}', 'var publicBase = appConfig.cdnURL || appConfig.baseURL || "/"', 'function joinURL (a, b) { return a[a.length -1] !== "/" ? a + "/" + b : a + b }', - 'globalThis.__publicAssetsURL = function(id) { return joinURL(publicBase, id) }', - 'globalThis.__buildAssetsURL = function(id) { return joinURL(publicBase, joinURL(appConfig.buildAssetsDir, id)) }', + 'globalThis.__publicAssetsURL = function(id) { return joinURL(publicBase, id || "") }', + 'globalThis.__buildAssetsURL = function(id) { return joinURL(publicBase, joinURL(appConfig.buildAssetsDir, id || "")) }', `var imports = ${JSON.stringify([...clientImports])};`, 'imports.reduce(function(p, id){return p.then(function(){return System.import(__buildAssetsURL(id).slice(1))})}, Promise.resolve())' ].join('\n') diff --git a/test/bridge.test.ts b/test/bridge.test.ts index 175d3919..9dca3a87 100644 --- a/test/bridge.test.ts +++ b/test/bridge.test.ts @@ -82,7 +82,8 @@ describe('dynamic paths', () => { await expectNoClientErrors('/assets') }) - it('adds relative paths to CSS', async () => { + // Vite legacy build does not emit CSS files + it.skipIf(!process.env.TEST_WITH_WEBPACK)('adds relative paths to CSS', async () => { const html = await $fetch('/assets') const urls = Array.from(html.matchAll(/(href|src)="(.*?)"/g)).map(m => m[2]) const cssURL = urls.find(u => /_nuxt\/assets.*\.css$/.test(u))