import { mergeConfig, type UserConfig } from 'vite';

export default (config: UserConfig) => {
  return mergeConfig(config, {
    plugins: [
      {
        name: 'fix-cropper-raw',
        resolveId(id) {
          if (id.includes('cropper.css?raw')) {
            return id;
          }
        },
        load(id) {
          if (id.includes('cropper.css?raw')) {
            // Return an empty string or a dummy CSS module to prevent the parser error
            return 'export default "";';
          }
        }
      }
    ],
    server: {
      host: '0.0.0.0',
      allowedHosts: true,
      hmr: {
        clientPort: 3000,
      },
      fs: {
        strict: false
      }
    }
  });
};
