From c1c1b287da6bfc9d53198f8275a9d155b466dd7e Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Mon, 5 Feb 2024 13:05:19 +0100 Subject: [PATCH] ci: fix source map missing pragma --- plugins/css_bundler/src/bundler.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/css_bundler/src/bundler.ts b/plugins/css_bundler/src/bundler.ts index c16a81d..e9c5d37 100644 --- a/plugins/css_bundler/src/bundler.ts +++ b/plugins/css_bundler/src/bundler.ts @@ -17,12 +17,22 @@ export async function bundleCss( try { const { code, map } = await builder({ filename, dev, assetDir }) - await Deno.writeFile(join(assetDir, pathname), code) if (map) { + //# sourceMappingURL=fresh_dev_client.js.map + const sourceMappingURL = new TextEncoder().encode( + `\n/*# sourceMappingURL=${pathname.replace('.css', '.map.css')} */`, + ) + await Deno.writeFile( + join(assetDir, pathname), + Uint8Array.of(...code, ...sourceMappingURL), + ) + await Deno.writeFile( join(assetDir, pathname.replace('.css', '.map.css')), map, ) + } else { + await Deno.writeFile(join(assetDir, pathname), code) } } catch (error) { Logger.error('error during bundle, cleaning cache', error)