1
0

vite.config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /// <reference types="vitest" />
  2. import ViteYaml from '@modyfi/vite-plugin-yaml'
  3. import babel from '@rollup/plugin-babel'
  4. import react from '@vitejs/plugin-react'
  5. import * as path from 'node:path'
  6. import { visualizer } from 'rollup-plugin-visualizer'
  7. import { defineConfig } from 'vite'
  8. import checker from 'vite-plugin-checker'
  9. import {
  10. AtlasHtmlMetaTagsPlugin,
  11. AtlasWebmanifestPlugin,
  12. EmbeddedFallbackPlugin,
  13. PolkadotWorkerMetaFixPlugin,
  14. } from './plugins'
  15. // https://vitejs.dev/config/
  16. export default defineConfig({
  17. root: './src',
  18. build: {
  19. target: ['chrome87', 'edge88', 'es2020', 'firefox78', 'safari14'],
  20. emptyOutDir: true,
  21. outDir: path.resolve(__dirname, 'dist'),
  22. rollupOptions: {
  23. input: {
  24. main: path.resolve(__dirname, 'src/index.html'),
  25. embedded: path.resolve(__dirname, 'src/embedded/index.html'),
  26. },
  27. },
  28. },
  29. server: {
  30. port: 3000,
  31. },
  32. test: {
  33. environment: 'happy-dom',
  34. setupFiles: ['vitest-setup.ts'],
  35. globals: true,
  36. },
  37. esbuild: {
  38. logOverride: { 'this-is-undefined-in-esm': 'silent' }, // workaround for vite, esbuild and babel integration bug: https://github.com/vitejs/vite/issues/8644
  39. },
  40. worker: {
  41. plugins: [PolkadotWorkerMetaFixPlugin],
  42. },
  43. plugins: [
  44. AtlasHtmlMetaTagsPlugin,
  45. AtlasWebmanifestPlugin,
  46. EmbeddedFallbackPlugin,
  47. ViteYaml(),
  48. react({
  49. exclude: /\.stories\.[tj]sx?$/,
  50. }),
  51. checker({
  52. typescript: true,
  53. eslint: {
  54. lintCommand: 'eslint "./**/*.{js,jsx,ts,tsx}"',
  55. dev: { overrideConfig: { ignorePath: '../.eslintignore' } },
  56. },
  57. overlay: false,
  58. }),
  59. babel({
  60. extensions: ['.tsx', '.ts'],
  61. include: ['**/*.style.*', '**/*.styles.*'],
  62. plugins: ['@emotion'],
  63. babelHelpers: 'bundled',
  64. }),
  65. {
  66. ...visualizer({
  67. filename: 'dist/stats.html',
  68. }),
  69. enforce: 'post',
  70. },
  71. ],
  72. resolve: {
  73. alias: {
  74. '@': path.resolve(__dirname, './src'),
  75. },
  76. },
  77. optimizeDeps: {
  78. include: ['buffer'],
  79. esbuildOptions: {
  80. define: {
  81. global: 'globalThis',
  82. },
  83. },
  84. },
  85. })