Created
March 28, 2022 22:36
-
-
Save fersilva16/8baba53401dee2a542ce3cc3d65b15c0 to your computer and use it in GitHub Desktop.
Vite with polyfills for Buffer and global
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from 'vite'; | |
import react from '@vitejs/plugin-react'; | |
import inject from '@rollup/plugin-inject'; | |
export default defineConfig(({ mode }) => { | |
return { | |
plugins: [react()], | |
build: | |
mode === 'production' | |
? { | |
rollupOptions: { | |
plugins: [inject({ Buffer: ['buffer', 'Buffer'] })], | |
}, | |
} | |
: undefined, | |
define: | |
mode === 'development' | |
? { | |
global: {}, | |
} | |
: undefined, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment