bennymeg / nx-electron

Electron schematics for nrwl nx platform
Apache License 2.0
328 stars 85 forks source link

Custom preload script does not seem to be packaged #155

Closed Gerolmed closed 2 years ago

Gerolmed commented 2 years ago

Describe the bug I have to preload scripts preload.ts and preload.game.ts. I adjusted the webpack config so it would properly build the second one: image But while everything works fine when I serve it out of the IDE, once I package it and try using that it wont find the preload.game.js but only the normal preload.js. I checked the app.asar file and also found it to be missing.

To Reproduce Steps to reproduce the behavior:

  1. nx run standalone-launcher:package
  2. the app.asar only contains preload.js and not preload.game.js

Additional Information webpack config in standalone-launcher folder:

module.exports = (config) => {
    config.entry = {
        ...config.entry,
        "preload.game": ['apps/standalone-launcher/src/app/api/preload.game.ts'],
    };
    return config;
};

Screenshots image

Desktop (please complete the following information):

bennymeg commented 2 years ago

this feature did not got merged at this build. You should specify to include this file manually at the maker options config file. I'll try to include it in the next release.

Gerolmed commented 2 years ago

How do I specify it in the config?

bennymeg commented 2 years ago

https://github.com/bennymeg/nx-electron/issues/139#issuecomment-1035495156

Gerolmed commented 2 years ago

Im not quite sure what the "root" is inside the nx project. Ive tried this:

"files": [{
        "from": "apps/standalone-launcher/src/app/api",
        "to": "standalone-launcher",
        "filter": "preload.game.js"
    }]

And it doesnt show up in the app.asar

bennymeg commented 2 years ago

As of v13 the preload scripts naming had been changed to ([name].)?preload.ts (i.e. main.preload.ts, preload.ts) As long as you keep this naming role and keep all the preload scripts in the api folder everything should be handled out of the box. Please test in again with the latest release and let me know if you still having issues.

Gerolmed commented 2 years ago

Works fine now. thx a lot!