Ctrl K
ComunidadGuías…

vite.config.mts

Rama develop · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
import { defineConfig } from 'vite';
import RailsVite from 'rails-vite-plugin';
import tailwindcss from '@tailwindcss/vite';
import { compression } from 'vite-plugin-compression2';
export default defineConfig(({ mode }) => ({
  plugins: [
    tailwindcss(),
    RailsVite({
      sourceDir: 'app/frontend',
      refresh: [
        'config/routes.rb',
        'app/views/**/*',
        'app/components/**/*',
        'app/**/*.rb',
        'config/locales/**/*.yml',
      ],
    }),
    compression({ algorithms: ['gzip', 'brotliCompress'] }),
  ],
  build: {
    rolldownOptions: {
      // A production build leaves out the test entrypoint. Its entries in the
      // manifest would make the service worker precache files the Docker image
      // does not have.
      input:
        mode === 'production'
          ? [
              'app/frontend/entrypoints/application.ts',
              'app/frontend/entrypoints/application.css',
            ]
          : undefined,
      output: {
        codeSplitting: {
          groups: [
            {
              name: 'chart',
              test: /node_modules\/(chart|luxon)/,
            },
            {
              name: 'hotwire',
              test: /node_modules\/(stimulus|@hotwired|@rails)/,
            },
            // Only the map of the car page imports it, on demand. In the
            // group below, each page would load it.
            {
              name: 'maplibre',
              test: /node_modules\/maplibre-gl/,
            },
            // Imported on demand, only with an API key (see setupHoneyBadger)
            {
              name: 'honeybadger',
              test: /node_modules\/@honeybadger-io/,
            },
            {
              name: 'other-vendor',
              test: /node_modules/,
            },
          ],
        },
      },
    },
  },
  // The worker of MapLibre imports a shared module, which needs the ES format
  worker: {
    format: 'es',
  },
  server: {
    port: 3036,
    hmr: {
      host: 'vite.solectrus.localhost',
      clientPort: 443,
      protocol: 'wss',
    },
  },
}));