Skip to content

Commit 5169dbf

Browse files
authored
feat(vite): support wasm asset file type (#314)
1 parent f4e82b4 commit 5169dbf

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

packages/client/src/components/assets/AssetListItem.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const icon = computed(() => {
3232
return 'i-carbon-document'
3333
if (props.item.type === 'json')
3434
return 'i-carbon-json'
35+
if (props.item.type === 'wasm')
36+
return 'i-vscode-icons-file-type-wasm'
3537
return 'i-carbon-document-blank'
3638
})
3739
</script>

packages/client/src/components/assets/AssetPreview.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ defineProps<{
2929
<div v-if="!detail" i-carbon-volume-up text-3xl op20 />
3030
<audio v-else :src="asset.publicPath" controls />
3131
</div>
32+
<div v-else-if="asset.type === 'wasm'" i-vscode-icons-file-type-wasm text-3xl />
3233
<div v-else i-carbon-help text-3xl op20 />
3334
</div>
3435
</template>

packages/core/src/vite-bridge/module-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// assets
2-
export type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'other'
2+
export type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'wasm' | 'other'
33
export interface AssetInfo {
44
path: string
55
type: AssetType

packages/vite/src/modules/assets.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ function guessType(path: string): AssetType {
5050
return 'font'
5151
if (/\.(json[5c]?|te?xt|[mc]?[jt]sx?|md[cx]?|markdown|ya?ml|toml)/i.test(path))
5252
return 'text'
53+
if (/\.wasm/i.test(path))
54+
return 'wasm'
5355
return 'other'
5456
}
5557

@@ -73,6 +75,8 @@ export function setupAssetsModule(options: { rpc: ViteInspectAPI['rpc'], server:
7375
'**/*.(woff2?|eot|ttf|otf|ttc|pfa|pfb|pfm|afm)',
7476
// text
7577
'**/*.(json|json5|jsonc|txt|text|tsx|jsx|md|mdx|mdc|markdown|yaml|yml|toml)',
78+
// wasm
79+
'**/*.wasm',
7680
], {
7781
cwd: dir,
7882
onlyFiles: true,

0 commit comments

Comments
 (0)