Custom domain on react-vite

I tried modifying the vite-config based on this one, so that maybe it can read the .ic-assets.json.

I modified it to this:

/// <reference types="vitest" />
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import environment from 'vite-plugin-environment';
import topLevelAwait from "vite-plugin-top-level-await";
import { viteStaticCopy } from 'vite-plugin-static-copy';
import dotenv from 'dotenv';

dotenv.config();

export default defineConfig({
  root: 'src',
  build: {
    outDir: '../dist',
    emptyOutDir: true,
  },
  optimizeDeps: {
    esbuildOptions: {
      define: {
        global: 'globalThis',
      },
    },
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:4943',
        changeOrigin: true,
      },
    },
  },
  plugins: [
    react(),
    environment('all'),
    topLevelAwait({
      promiseExportName: "__tla",
      promiseImportName: i => `__tla_${i}`
    }),
    viteStaticCopy({
      targets: [
        {
          src: 'src/assets/.ic-assets.json5',
          dest: '.',
        },
      ],
    }),
  ],
  test: {
    environment: 'jsdom',
    cache: { dir: '../node_modules/.vitest' },
  },
});

But now when I run the project I am getting this error:


✘ [ERROR] "vite-plugin-static-copy" resolved to an ESM file. ESM file cannot be loaded by `require`. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]

    node_modules/esbuild/lib/main.js:1374:27:
      1374 │         let result = await callback({


The plugin "externalize-deps" was triggered by this import

    vite.config.ts:6:31:
      6 │ import { viteStaticCopy } from 'vite-plugin-static-copy';
        ╵                                ~~~~~~~~~~~~~~~~~~~~~~~~~

failed to load config from /home/enoch/aworkspace/fun/IC-ToDo/mytodo/vite.config.ts
error when starting dev server:
Error: Build failed with 1 error: