Closed kainstar closed 1 year ago
I can't seem to reproduce this problem, but maybe you can add this configuration after Line:136
in vite.config.ts
.
optimizeDeps: {
entries: [
path.resolve(__dirname, 'index.html'),
path.resolve(__dirname, 'eval-logs.html')
]
},
If this fixes your problem, I'll add it to the project.
Is your problem bound to recur?
I tried add the optimizeDeps
property and console.log
in replacer plugin, but don't take any effects.
But after I revert all my changes, the vite don't report error any more. I'm confused with the reason why it report and why it don't report. Maybe the cache, dependencies version or OS?
Anyways, I escape from the strange problem, I will close this issue later.
So strange, Vite.
I found out how to solve it! The error will appear when you not access the application link.
It will resolve when you to access the http://localhost:5173/app
.
Vite seem needed cache the external dependency when you access the web application, I think it which wrong resolving by vite-plugin-external
.
cc @nonzzz
@AfireHong You can try the resolve method.
Here's the reproduce & workaround screencast:
https://github.com/Power-Playground/app/assets/28441561/90985c49-36bf-43f5-b44a-82f6dc8f18f2
Now, I find the why. This problem is about to be solved.
Let us know what happens with this wrong. First, we run the vite dev server, And vite will create a viteServer
us plugin and vite's internal plugin will extract some hook and called on middlewares
The first called will happen on function resolveConfig
. And each plugin who has config
will be trigger then merge the config. Then vite's server has been listen. It will check each plugin state(ensure plugins are ready) and start scan and pre build logic.(Notice it)
vite create vite:scan
for scan each input. and using esbuild pre build ( Now us config.ts
is using
import.meta.glob(Variable)
, but the variable
is define on replacer plugin. but it don't be trigger on scan stage. So the esbuild will send panic. But if you open the project. The replacer plugin will work. So it's bind variable success.
When run
yarn serve
, I get some errors in my terminal, but the url http://localhost:5174/app/ can be access normally.Is there any additional operation need to do after install node_modules?
Logs
Envs