Skip to content

Commit bc76d9f

Browse files
author
Austin
committed
Fix truncation for compiled theme assets by using byte length
1 parent 7bec61c commit bc76d9f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/theme/src/cli/utilities/theme-environment/local-assets.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {injectCdnProxy} from './proxy.js'
22
import {parseServerEvent} from './server-utils.js'
33
import {getLiquidTagContent} from './liquid-tag-content.js'
44
import {lookupMimeType} from '@shopify/cli-kit/node/mimes'
5+
import {Buffer} from 'node:buffer'
56
import {defineEventHandler, H3Event, serveStatic, setResponseHeader, sendError, createError} from 'h3'
67
import {joinPath} from '@shopify/cli-kit/node/path'
78
import type {Theme, ThemeAsset, VirtualFileSystem} from '@shopify/cli-kit/node/themes/types'
@@ -130,7 +131,7 @@ function handleStylesCss(ctx: DevServerContext, event: H3Event) {
130131

131132
return serveStatic(event, {
132133
getContents: () => stylesheet,
133-
getMeta: () => ({type: 'text/css', size: stylesheet.length, mtime: new Date()}),
134+
getMeta: () => ({type: 'text/css', size: Buffer.byteLength(stylesheet), mtime: new Date()}),
134135
})
135136
}
136137

@@ -190,7 +191,7 @@ function handleBlockScriptsJs(ctx: DevServerContext, event: H3Event, kind: 'bloc
190191

191192
return serveStatic(event, {
192193
getContents: () => javascript,
193-
getMeta: () => ({type: 'text/javascript', size: javascript.length, mtime: new Date()}),
194+
getMeta: () => ({type: 'text/javascript', size: Buffer.byteLength(javascript), mtime: new Date()}),
194195
})
195196
}
196197

0 commit comments

Comments
 (0)