
The hash key used to invalidate optimized dependencies depend on the package lock contents, the patches applied to dependencies, and the options in the Vite config file that affects the bundling of node modules. Optimized Dependencies Outdated pre-bundled deps when linking to a local package The easiest way to achieve this is to run npx vite preview. You will need to access the file with http protocol. See Reason: CORS request not HTTP - HTTP | MDN for more information about why this happens. If the HTML file output was opened with file protocol, the scripts won't run with the following error.Īccess to script at 'file:///foo/bar.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.Ĭross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///foo/bar.js.


Build Built file does not work because of CORS error This can be caused by a circular dependency. If HMR is not handled by Vite or a plugin, a full reload will happen.Īlso if there is a dependency loop, a full reload will happen.

If you are running Vite with WSL2, Vite cannot watch file changes in some conditions. Related issue: #964 Vite does not detect a file change Click "Ignore" on that dialog, set up the server mapping, and try again, and you should get a proper debug session.Js import '. Then click "Listen for debug connections" in the toolbar, and run your script a dialog box should pop up showing the "Server name:" and "Server port:" it is trying to match, as well as confirming the remote file path. To find out what details you need to set up, go into "Settings > Languages and Frameworks > PHP > Debug", enable "Force break at the first line when no path mapping specified", and make sure "Ignore external connections through unregistered server configurations" is not ticked. For CLI scripts, the info to put in here will be based on your connection to the server where the CLI script runs. Normally, you would enter a URL into "Host" and set "Port" to the HTTP port, e.g.

You need to set up a "server" configuration in "Settings > Languages and Frameworks > PHP > Servers" which maps the paths as seen on the server to the paths in your project.
