We can't start Vite in dev mode because the manifest-loader plugin needs to effectively build everything so it can output a manifest with all the outputs listed in it
HMR only works for HTML pages, like V1
From the client pages, we can't load the scripts from http://localhost:3000 because of Chrome's rules against loading external code. It just blocks the file from being downloaded
So instead of serving a file over localhost when there's a change, we write that file to the output director and send a message to the client telling it to HMR, but based off a file path instead of a URL (http://localhost:3000/popup/index.js → /popup/index.js). These files can be loaded correctly!
Todo
[x] Spin up server when running with HMR enabled
[x] Write files to server instead of hosting them on localhost
[x] Write entry point "templates" while loading the scripts and CSS files
Couple of comments:
http://localhost:3000
because of Chrome's rules against loading external code. It just blocks the file from being downloadedSo instead of serving a file over localhost when there's a change, we write that file to the output director and send a message to the client telling it to HMR, but based off a file path instead of a URL (
http://localhost:3000/popup/index.js
→/popup/index.js
). These files can be loaded correctly!Todo