I am trying to package my electron angular project using Electron packager. The packager packages the application without errors, but when laucnhing the application with the .exe file none of the assets loads correctly. In developement mode the assets works correctly, only when packaging the application it does not work correctly.
The Angular project consists of multiple libraries and applications as follows:
Root
--> Projects
--> Desktop
--> Mobile
--> Library 1
--> Library 2
The assets are in both libraries 1 and 2, but upon building all the assets gets consolidated into a single assets folder.
I am trying to package the Desktop application with electron in this case.
The output of the dist/desktop folder when buidling the desktop application in production
All the assets inside are correct.
Then the packaging command from electron packager:
electron-packager ./dist/desktop MyAppName --overwrite --asar --platform=win32 --arch=x64 --icon=projects/desktop/src/assets/logo-accent.ico --prune=true --out=dist --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"MyAppName\""
The app.asar file is generated correctly inside the resources folder within the packaged application.
Output error of an assets file when running the application:
I created a dummby app and noticed that the assets work correctly and the path of the file should be in thefollowing format:
Hence the red part is missing in my original project. How would I fix this issue?
The assets folder from my Library 1 was in the root folder. I moved the assets folder into src folder in Library 1 and updated all the references to 'assets/...' instead of '../assets...' and it worked correctly.