Skip to content

Commit b2a8de0

Browse files
committed
fix: resolve Buffer through browser entrypoint
1 parent 95e042b commit b2a8de0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

nuxt-config/hooks/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ const HELIX_OPTIMIZE_DEPS = [
3838
'@shared/transformer/oracle'
3939
]
4040

41+
function aliasBufferEntrypoint(config: any) {
42+
config.resolve = config.resolve || {}
43+
44+
if (Array.isArray(config.resolve.alias)) {
45+
config.resolve.alias.push({ find: /^buffer$/, replacement: 'buffer/' })
46+
47+
return
48+
}
49+
50+
config.resolve.alias = {
51+
...(config.resolve.alias || {}),
52+
buffer: 'buffer/'
53+
}
54+
}
55+
4156
export default {
4257
'pages:extend'(pages) {
4358
const spotPage = pages.find((page) => page.name === TradePage.Spot)
@@ -81,6 +96,8 @@ export default {
8196
]
8297
},
8398
'vite:extendConfig'(config: any) {
99+
aliasBufferEntrypoint(config)
100+
84101
if (isProduction) {
85102
return
86103
}

0 commit comments

Comments
 (0)