electron / electron/forge

Can't set angular as renderer in production

Open
#3,937 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 1h
Merged PRs (30d)
30

Description

### Pre-flight checklist

- [x] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

### Forge version

7.8.1

### Electron version

36.2.0

### Operating system

windows 1 0

### Last known working Forge version

_No response_

### Expected behavior

The only way I found to electron forge to run in production with built angular files is a way which breaks preload.js dir resolution.

**See below:**

I'm able to load angular url in devlopment:

` mainWindow.loadURL("http://localhost:4200");
`

but to be able to load the built html + js + css in production I must to set built angular as extraResource:

```
const config: ForgeConfig = {
packagerConfig: {
asar: true,
extraResource: [
"../angular/dist/rfid-desktop/browser"
],
```

and

plugins: [
new VitePlugin({
....
renderer: [],

when I do that and build application the electron app opens with the loaded angular content (path.join(__dirname, '..','..','..','browser','index.html');).

The issue is angular files (in built electron) is out of app.asar then preload.js is not solved. If I disable asar the app just don't start up.

Below is my package json snap:

```
"scripts": {
"start": "concurrently \"cd ../angular && ng serve && cd ../electron\" \"wait-on tcp:4200 && cross-env NODE_ENV=development electron-forge start\"",
"package": "electron-forge package",
"build":"cd ../angular && ng build && cd ../electron && npm run package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "eslint --ext .ts,.tsx ."
},
```

### Actual behavior

.

### Steps to reproduce

.

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.