Source:  Twitter logo

I have a React project with set up with vite and ts. Without ts I do have the overlay errors as we used to have errors with a basic react project.

import { defineConfig } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh';
const path = require('path');

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: [
      { find: '@', replacement: path.resolve(__dirname, '/src') },
      {
        find: '@components',
        replacement: path.resolve(__dirname, '/src/components'),
      },
      { find: '@pages', replacement: path.resolve(__dirname, '/src/pages') },
    ],
  },
  plugins: [reactRefresh()],

});

It's look like reactRefresh() never show up the overlay .

I did tray to set it up in vite.config.ts

 hmr: { overlay: true },

of even

  server: {
    hmr: { overlay: true },
  },
11:16:09 AM [vite] Internal server error: Transform failed with 1 error:
/mnt/mydata/src/App.tsx:2:38: error: Unterminated string literal
  Plugin: vite:esbuild
  File: /mnt/mydata/src/App.tsx
  
  Unterminated string literal
  1  |  import React, { useState } from 'react';
  2  |  import Navbar from '@components/Navbar
     |                                        ^
  3  |  import './App.css';
  4  |  const App = () => {
  
      at failureErrorWithLog (/mnt/mydata/node_modules/esbuild/lib/main.js:1493:15)
      at /mnt/mydata/node_modules/esbuild/lib/main.js:1282:29
      at /mnt/mydata/node_modules/esbuild/lib/main.js:629:9
      at handleIncomingPacket (/mnt/mydata/node_modules/esbuild/lib/main.js:726:9)
      at Socket.readFromStdout (/mnt/mydata/node_modules/esbuild/lib/main.js:596:7)
      at Socket.emit (node:events:390:28)
      at addChunk (node:internal/streams/readable:315:12)
      at readableAddChunk (node:internal/streams/readable:289:9)
      at Socket.Readable.push (node:internal/streams/readable:228:10)
      at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
11:16:11 AM [vite] page reload src/App.tsx

An exemple of hmr overlay with react vite and jsx :

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).