Perfect timing! I just had a question on this and your article solved the problem I had! I tried and it works beautifully!
Just a couple of minor improvements:
!/usr/bin/env node as the first line and then running chmod +x build.js scripts section in package.json can be updated to run this script when npm run build is called:"scripts": {
"start": "vite",
"dev": "vite",
"build": "./build.js",
"serve": "vite preview"
},
For typescript, I found that I simply needed to change the entryPoints value to entryPoints: ["src/index.tsx"],.