build-electron icon indicating copy to clipboard operation
build-electron copied to clipboard

Where do I put my HTML file?

Open eltoroit opened this issue 3 years ago • 1 comments

Hi. I am new to Electron and I am using your solution to use ESM and CommonJS modules. THANK YOU for building that.

Everything works when I run this code in VS Code in debug mode, but I am not having luck when the project is built into an executable file. The EXE is complaining that it can't find the HTML files, and I do not see them anywhere in the dist folder. How do I copy the files, so that when the project is built the files are also copied?

If the HTML file is compiled, then how to I load the file in the window.loadFile(homepage);?

Thanks

eltoroit avatar Mar 24 '23 21:03 eltoroit

Hi. You can use some frontend build tool like create-react-app or vite. Then maybe something like this:

const url = new URL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../vite-dist/index.html')}`);

mifi avatar Mar 25 '23 09:03 mifi