我正试着用Electron 打包机打包我的Electron 角项目.打包程序将应用程序打包时没有错误,但在使用.exe文件加载应用程序时,没有正确加载任何assets资源 .在开发模式下,assets资源 可以正常工作,只有在打包应用程序时才不能正常工作.

ANGLE项目由多个库和应用程序组成,如下所示:

Root
  --> Projects
    --> Desktop
    --> Mobile
    --> Library 1
    --> Library 2

assets资源 位于库1和库2中,但在构建时,所有assets资源 都合并到单个assets资源 文件夹中.

在这种情况下,我正在try 用Electron 打包Desktop个应用程序.

The output of the dist/desktop folder when buidling the desktop application in production

enter image description here

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:

enter image description here

I created a dummby app and noticed that the assets work correctly and the path of the file should be in thefollowing format: enter image description here

因此,我的原始项目中缺少红色部分.我该如何解决这个问题?

推荐答案

My Library 1中的Assets文件夹位于根文件夹中.我将Assets文件夹移到了库1的src文件夹中,并更新了对‘Assets/...’的所有引用.而不是‘../assets资源 ...’而且它运行正常.

Angular相关问答推荐

FormArray包含嵌套的FormGroups.如何访问嵌套的表单组控件?

Angular 16未知参数:独立

以Angular 表示显示特殊字符

带有两个注入服务的函数式解析器(Angular 15)

如何用Effect()识别正确的Angular 信号?

从、管道和映射可观察到的逻辑?

Angular 如何渲染ngFor?

如何使用独立组件在ANGLE(16+)中实现嵌套布线

Angular 单调服务已多次创建

所有返回缺少权限或权限不足的FireBase项目.

react 形式之间的循环关系

Angular 路由中的模块构建失败

Observable转换为Observable

全局异常处理

无法读取 angular2 中未定义(…)的属性 push

如何设置Angular 4背景图片?

Angular 5 Mat-grid 列表响应式

Angular 4.3拦截器不起作用

Angular为 4 的可扩展表格行,带有Angularmaterial

实现autocomplete功能