title: Rollup failed to resolve import "src/bootstrap.tsx" from "index.html"
body: <p><strong>The problem :</strong></p>
  <p>This is what happens when i run the build with my React/Vite app :</p>
  <pre><code>vite v2.9.6 building for production...
  ✓ 1 modules transformed.
  
  ERROR  [vite]: Rollup failed to resolve import &quot;src/bootstrap.tsx&quot; from &quot;index.html&quot;.
  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to        
  `build.rollupOptions.external`
  </code></pre>
  <p>Expected result : A successful build.</p>
  <p>In dev mode everything works fine.</p>
  <p><strong>What i tried :</strong></p>
  <p>Here a <a href="https://stackoverflow.com/a/69170378/16427621">solution</a> which proposes to add &quot;/&quot; to the path of the script in index.html, but it is already the case in my code and it does not work. I still tried without &quot;/&quot;, just in case.</p>
  <p><strong>Some of my code :</strong></p>
  <p>in index.html:</p>
  <pre><code>&lt;script type=&quot;module&quot; src=&quot;/src/bootstrap.tsx&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>in vite.config.ts :</p>
  <pre><code>import { defineConfig, loadEnv } from 'vite';
  import react from '@vitejs/plugin-react';
  import path from 'path';
  import { viteStaticCopy } from 'vite-plugin-static-copy';
  import { viteCommonjs, esbuildCommonjs } from '@originjs/vite-plugin-commonjs';
  import viteCompression from 'vite-plugin-compression';
  import { createHtmlPlugin } from 'vite-plugin-html';
    
  export default defineConfig(({ mode }) =&gt; {
    const env = loadEnv(mode, process.cwd(), 'VITE_');
  
    const publicPath = '/';
    const productName = 'My product name';
  
    return {
      define: {
        PUBLIC_PATH: JSON.stringify(publicPath),
        PRODUCT_NAME: JSON.stringify(productName),
      },
      plugins: [
        react({
          jsxRuntime: 'classic',
        }),
        viteStaticCopy({
          flatten: true,
          targets: [
            {
              src: 'node_modules/@client-ux/mylib/assets/fonts',
              dest: './assets',
            },
          ],
        }),
        viteCommonjs(),
        viteCompression({
          threshold: 1024 * 8, // 8 KB
          deleteOriginFile: false,
          filter: /\.(js|json|ttf|eot|woff|otf)$/i,
        }),
        createHtmlPlugin({
          entry: 'src/bootstrap.tsx',
          inject: {
            data: {
              title: `&lt;title&gt;${productName}&lt;/title&gt;`,
            },
          },
        }),
      ],
      optimizeDeps: {
        esbuildOptions: {
          plugins: [esbuildCommonjs(['@client-ux/mylib-react', '@otherlib/front-common'])],
        },
      },
      resolve: {
        alias: {
          '@src': path.resolve(__dirname, 'src'),
          '@root': path.resolve(__dirname, './'),
          '@public': path.resolve(__dirname, './public'),
          '@cypress': path.resolve(__dirname, './cypress'),
          '@dist': path.resolve(__dirname, './dist'),
        },
      },
      css: {
        preprocessorOptions: {
          scss: {
            additionalData: `
              $mylib-fonts-path: &quot;.${publicPath}${mode === 'development' ? 'assets/' : ''}&quot;;
              @import &quot;./src/shared/styles/variables&quot;;
              @import &quot;./src/shared/styles/mixins&quot;;
              @import &quot;./node_modules/@client-ux/mylib-core/src/app/styles/common/_default.scss&quot;;
            `,
          },
        },
      },
      build: {
        reportCompressedSize: false,
      },
    };
  });
  </code></pre>