Skip to content

Commit e8d3ffd

Browse files
committedJan 3, 2024
fix: maybe fix cloudflare pages wasm resolving for css-inline
1 parent 5d6151d commit e8d3ffd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎src/build/build.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readFile, writeFile } from 'node:fs/promises'
2+
import { existsSync } from 'node:fs'
23
import { createHash } from 'node:crypto'
34
import { type Resolver, resolvePath, useNuxt } from '@nuxt/kit'
45
import type { Nuxt } from '@nuxt/schema'
@@ -48,6 +49,14 @@ export async function setupBuildHandler(config: ModuleOptions, resolve: Resolver
4849
.replaceAll('"@resvg/resvg-wasm/index_bg.wasm"', `"${path}index_bg-${resvgHash}.wasm${postfix}"`)
4950
.replaceAll('"@css-inline/css-inline-wasm/index_bg.wasm"', `"${path}index_bg-${cssInlineHash}.wasm${postfix}"`)
5051
.replaceAll('"yoga-wasm-web/dist/yoga.wasm"', `"${path}yoga-${yogaHash}.wasm${postfix}"`), { encoding: 'utf-8' })
52+
// TODO remove with next nitro bump
53+
if (target.includes('cloudflare')) {
54+
const imgChunk = resolve(dirname(serverEntry), './chunks/handlers/image.mjs')
55+
existsSync(imgChunk) && await writeFile(imgChunk, (await readFile(serverEntry, 'utf-8'))
56+
.replaceAll('"@resvg/resvg-wasm/index_bg.wasm"', `"${path}index_bg-${resvgHash}.wasm${postfix}"`)
57+
.replaceAll('"@css-inline/css-inline-wasm/index_bg.wasm"', `"${path}index_bg-${cssInlineHash}.wasm${postfix}"`)
58+
.replaceAll('"yoga-wasm-web/dist/yoga.wasm"', `"${path}yoga-${yogaHash}.wasm${postfix}"`), { encoding: 'utf-8' })
59+
}
5160
})
5261
})
5362
}

0 commit comments

Comments
 (0)