Guest User

Untitled

a guest
May 1st, 2022
146
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 GlobalsPolyfills from '@esbuild-plugins/node-globals-polyfill';
  5. import NodeModulesPolyfills from '@esbuild-plugins/node-modules-polyfill';
  6. import rollupNodePolyFill from 'rollup-plugin-node-polyfills';
  7. // @ts-ignore
  8. import path from 'path';
  9. // @ts-ignore
  10. import svgrPlugin from 'vite-plugin-svgr';
  11.  
  12. // https://vitejs.dev/config/
  13. export default defineConfig({
  14.   plugins: [
  15.     EnvironmentPlugin(
  16.       {
  17.         REACT_APP_BLOCKCHAIN_BASE_URL: undefined,
  18.         STATE: undefined,
  19.       },
  20.       { loadEnvFiles: true }
  21.     ),
  22.     svgrPlugin({
  23.       svgrOptions: {
  24.         icon: true,
  25.       },
  26.     }),
  27.     ,
  28.     react(),
  29.   ],
  30.   resolve: {
  31.     alias: {
  32.       // This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
  33.       // see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts
  34.       // process and buffer are excluded because already managed
  35.       // by node-globals-polyfill
  36.       util: 'rollup-plugin-node-polyfills/polyfills/util',
  37.       sys: 'util',
  38.       events: 'rollup-plugin-node-polyfills/polyfills/events',
  39.       stream: 'rollup-plugin-node-polyfills/polyfills/stream',
  40.       path: 'rollup-plugin-node-polyfills/polyfills/path',
  41.       querystring: 'rollup-plugin-node-polyfills/polyfills/qs',
  42.       punycode: 'rollup-plugin-node-polyfills/polyfills/punycode',
  43.       url: 'rollup-plugin-node-polyfills/polyfills/url',
  44.       http: 'rollup-plugin-node-polyfills/polyfills/http',
  45.       https: 'rollup-plugin-node-polyfills/polyfills/http',
  46.       os: 'rollup-plugin-node-polyfills/polyfills/os',
  47.       assert: 'rollup-plugin-node-polyfills/polyfills/assert',
  48.       constants: 'rollup-plugin-node-polyfills/polyfills/constants',
  49.       _stream_duplex:
  50.         'rollup-plugin-node-polyfills/polyfills/readable-stream/duplex',
  51.       _stream_passthrough:
  52.         'rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough',
  53.       _stream_readable:
  54.         'rollup-plugin-node-polyfills/polyfills/readable-stream/readable',
  55.       _stream_writable:
  56.         'rollup-plugin-node-polyfills/polyfills/readable-stream/writable',
  57.       _stream_transform:
  58.         'rollup-plugin-node-polyfills/polyfills/readable-stream/transform',
  59.       timers: 'rollup-plugin-node-polyfills/polyfills/timers',
  60.       console: 'rollup-plugin-node-polyfills/polyfills/console',
  61.       vm: 'rollup-plugin-node-polyfills/polyfills/vm',
  62.       zlib: 'rollup-plugin-node-polyfills/polyfills/zlib',
  63.       tty: 'rollup-plugin-node-polyfills/polyfills/tty',
  64.       domain: 'rollup-plugin-node-polyfills/polyfills/domain',
  65.       '@': path.resolve(__dirname, './src'),
  66.     },
  67.   },
  68.   optimizeDeps: {
  69.     esbuildOptions: {
  70.       plugins: [
  71.         NodeModulesPolyfills(),
  72.         GlobalsPolyfills({
  73.           process: true,
  74.           buffer: true,
  75.         }),
  76.       ],
  77.       define: {
  78.         global: 'globalThis',
  79.       },
  80.     },
  81.   },
  82.   build: {
  83.     rollupOptions: {
  84.       plugins: [rollupNodePolyFill()],
  85.     },
  86.   },
  87. });
  88.  
Advertisement
Add Comment
Please, Sign In to add comment