all repos — snow-editor @ 970ebf52cf5910cc2f16975f6021a80ada3a308a

small and cozy markdown, and orgmode editor

vite.config.js (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import {
  previewServerOptions,
  resolveAllowSearchIndexing,
  resolveAllowedHosts,
  robotsSeoPlugin,
} from './vite.shared.js';

export default defineConfig(({ mode }) => {
  const allowedHosts = resolveAllowedHosts(mode);
  const allowSearchIndexing = resolveAllowSearchIndexing(mode);

  return {
    plugins: [react(), robotsSeoPlugin(allowSearchIndexing)],
    build: {
      target: 'es2020',
      rollupOptions: {
        output: {
          manualChunks(id) {
            if (id.includes('node_modules/react-dom') || id.includes('node_modules/react/')) {
              return 'vendor-react';
            }
            if (id.includes('node_modules/marked') || id.includes('node_modules/dompurify')) {
              return 'vendor-markdown';
            }
          },
        },
      },
    },
    server: {
      ...previewServerOptions,
      allowedHosts,
      proxy: {
        '/api': {
          target: 'http://localhost:41738',
          changeOrigin: true,
        },
      },
    },
    preview: {
      ...previewServerOptions,
      allowedHosts,
      proxy: {
        '/api': {
          target: 'http://localhost:41738',
          changeOrigin: true,
        },
      },
    },
  };
});