Closed SouthLink closed 2 years ago
Hello @SouthLink. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction
will be closed if they have no activity within 3 days.
I update a Vite plugin to solve this problem vite-plugin-backend-hmr
That is one of the intended ways to make HMR work with backend integration. Vite does not/cannot know which files are used so a plugin is needed to handle by Vite.
这是使 HMR 与后端集成一起工作的预期方法之一。 Vite 不知道/不能知道使用了哪些文件,因此 Vite 需要一个插件来处理。
I found that HMR in the HTML file is success, but HMR in the PHP file fails. After searching, I found that in the deep level introduction, vite hmr only updates the current file and does not update to the top parent component, so the hot update fails. So I used the module importers the file to find the top-level component update. Isthat right please?
Ah, I understand what you were saying about.
This was because you were importing http://localhost:3009/@react-refresh
in index.php
.
import RefreshRuntime from 'http://localhost:3009/@react-refresh'
This should be importing http://localhost:3009/dist/@react-refresh
. (index.html
has this, so it's working.)
Related issue: #5656
Describe the bug
The hmr failure was encountered in the back-end(PHP) integrated multi-page mode. everything worked fine when a single component was introduced
The latest update..
Details please refer to the smallest copy, when I use to start the project with http://localhost:3009/dist/index.html access, HMR is normal,By introducing father http://localhost:3009/dist/index.php PHP file parent components can do normal HMR, child components HMR fails
I think it's because PHP files don't support refreshing
Because my current project is very old, PHP version 5.6, and does not use the Laravel framework
What should I do to use hot update mode normally
Reproduction
minimal reproducible example
System Info
Used Package Manager
npm
Logs
No response
Validations