Skip to content

Instantly share code, notes, and snippets.

@sadiqsalau
Last active December 26, 2022 09:32
Show Gist options
  • Save sadiqsalau/872a12a0d44882f9e492290270c57e21 to your computer and use it in GitHub Desktop.
Save sadiqsalau/872a12a0d44882f9e492290270c57e21 to your computer and use it in GitHub Desktop.
Vite Polyfills
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.polyfills.ts", "vite.config.ts"]
}
import { defineConfig } from 'vite'
import polyfills from "./vite.config.polyfills"
// https://vitejs.dev/config/
export default defineConfig({
...polyfills
})
/**
* pnpm add -D esbuild-plugins-node-modules-polyfill rollup-plugin-polyfill-node
*/
import nodePolyfills from "rollup-plugin-polyfill-node";
import { defineConfig } from "vite";
import { nodeModulesPolyfillPlugin } from "esbuild-plugins-node-modules-polyfill";
export default defineConfig({
optimizeDeps: {
esbuildOptions: {
// Enable esbuild polyfill plugins
plugins: [nodeModulesPolyfillPlugin()],
},
},
build: {
rollupOptions: {
plugins: [nodePolyfills()],
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment