Skip to content

Instantly share code, notes, and snippets.

@fersilva16
Created March 28, 2022 22:36
Show Gist options
  • Save fersilva16/8baba53401dee2a542ce3cc3d65b15c0 to your computer and use it in GitHub Desktop.
Save fersilva16/8baba53401dee2a542ce3cc3d65b15c0 to your computer and use it in GitHub Desktop.
Vite with polyfills for Buffer and global
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