Skip to content

Commit

Permalink
💩 Polyfill process with unenv
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Dec 10, 2024
1 parent 2ca37e2 commit d89de96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { replaceCodePlugin } from 'vite-plugin-replace'

Expand Down Expand Up @@ -62,12 +63,17 @@ export default defineNuxtConfig({

plugins: ['~/plugins/buffer.ts'],

alias: {
// polyfill process
process: path.resolve(__dirname, 'node_modules/unenv/runtime/node/process')
},
vite: {
define: {
global: 'globalThis'
},
plugins: [
nodePolyfills({
// global breaks on dev
globals: {
process: false,
Buffer: false,
Expand Down
2 changes: 2 additions & 0 deletions plugins/buffer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Buffer } from 'buffer'
import process from 'node:process'

globalThis.Buffer = Buffer
globalThis.process = process

export default defineNuxtPlugin((_) => {
})

0 comments on commit d89de96

Please sign in to comment.