Guest User

Untitled

a guest
May 3rd, 2022
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { defineConfig } from 'vite';
  2. import react from '@vitejs/plugin-react';
  3. import EnvironmentPlugin from 'vite-plugin-environment';
  4. import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
  5. // yarn add --dev @esbuild-plugins/node-modules-polyfill
  6. import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
  7. // You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
  8. import rollupNodePolyFill from 'rollup-plugin-node-polyfills';
  9. // @ts-ignore
  10. import path from 'path';
  11. // @ts-ignore
  12. import svgrPlugin from 'vite-plugin-svgr';
  13. // https://vitejs.dev/config/
  14. export default defineConfig({
  15.   plugins: [
  16.     EnvironmentPlugin(
  17.       {
  18.         REACT_APP_BLOCKCHAIN_BASE_URL: undefined,
  19.         STATE: undefined,
  20.       },
  21.       { loadEnvFiles: true }
  22.     ),
  23.     svgrPlugin({
  24.       svgrOptions: {
  25.         icon: true,
  26.       },
  27.     }),
  28.     ,
  29.     react(),
  30.     rollupNodePolyFill(),
  31.   ],
  32.   resolve: {
  33.     alias: {
  34.       // This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
  35.       // see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts
  36.       // process and buffer are excluded because already managed
  37.       // by node-globals-polyfill
  38.       util: 'util/util',
  39.  
  40.       sys: 'rollup-plugin-node-polyfills/polyfills/util',
  41.       events: 'rollup-plugin-node-polyfills/polyfills/events',
  42.       stream: 'rollup-plugin-node-polyfills/polyfills/stream',
  43.       path: 'rollup-plugin-node-polyfills/polyfills/path',
  44.       querystring: 'rollup-plugin-node-polyfills/polyfills/qs',
  45.       punycode: 'rollup-plugin-node-polyfills/polyfills/punycode',
  46.       url: 'rollup-plugin-node-polyfills/polyfills/url',
  47.       // string_decoder: 'rollup-plugin-node-polyfills/polyfills/string-decoder', // throwing me an error
  48.       http: 'rollup-plugin-node-polyfills/polyfills/http',
  49.       https: 'rollup-plugin-node-polyfills/polyfills/http',
  50.       os: 'rollup-plugin-node-polyfills/polyfills/os',
  51.       assert: 'rollup-plugin-node-polyfills/polyfills/assert',
  52.       constants: 'rollup-plugin-node-polyfills/polyfills/constants',
  53.       _stream_duplex:
  54.         'rollup-plugin-node-polyfills/polyfills/readable-stream/duplex',
  55.       _stream_passthrough:
  56.         'rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough',
  57.       _stream_readable:
  58.         'rollup-plugin-node-polyfills/polyfills/readable-stream/readable',
  59.       _stream_writable:
  60.         'rollup-plugin-node-polyfills/polyfills/readable-stream/writable',
  61.       _stream_transform:
  62.         'rollup-plugin-node-polyfills/polyfills/readable-stream/transform',
  63.       timers: 'rollup-plugin-node-polyfills/polyfills/timers',
  64.       console: 'rollup-plugin-node-polyfills/polyfills/console',
  65.       vm: 'rollup-plugin-node-polyfills/polyfills/vm',
  66.       zlib: 'rollup-plugin-node-polyfills/polyfills/zlib',
  67.       tty: 'rollup-plugin-node-polyfills/polyfills/tty',
  68.       domain: 'rollup-plugin-node-polyfills/polyfills/domain',
  69.       '@': path.resolve(__dirname, './src'),
  70.     },
  71.   },
  72.   optimizeDeps: {
  73.     esbuildOptions: {
  74.       plugins: [
  75.         NodeModulesPolyfillPlugin(),
  76.         NodeGlobalsPolyfillPlugin({
  77.           process: true,
  78.           buffer: true,
  79.         }),
  80.       ],
  81.       define: {
  82.         global: 'globalThis',
  83.       },
  84.     },
  85.   },
  86.   build: {
  87.     rollupOptions: {
  88.       plugins: [rollupNodePolyFill()],
  89.     },
  90.   },
  91. });
  92.  
Advertisement
Add Comment
Please, Sign In to add comment