Deluze / electron-vue-template

Simple Vue3 + Electron starter template in TypeScript, including ViteJS and Electron Builder
MIT License
534 stars 104 forks source link

static resource not found on build #36

Closed sebapusch closed 1 year ago

sebapusch commented 1 year ago

I am developing an application using this template and everything works fine on the dev server.

When building the application (for windows), when starting the it I get an error stating that a file under static folder is not found:

Error: ENOENT, static\resources\settings.json not found

The code:

const appPath = app.getAppPath();
join(appPath, 'static/resources', 'settings.json');

Do you know what I am doing wrong? Thanks in advance

Deluze commented 1 year ago

As it's working on the dev server I assume the file truly does exist. What's your Electron Builder config like? Have you made any changes to that?

Deluze commented 1 year ago

Also unpacking the asar file in dist/win-unpacked/rescources/app.asar will show you how the directories look on build. app.asar should contain the following structure:

- build/
- node_modules/
- renderer/
- static/
- package.json

I assume static/ is missing on your build?

sebapusch commented 1 year ago

@Deluze thank you. I realized for some reason I removed the static folder from the build configuration (not sure why). Everything is working as expected. Thank you for the great template