Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple preload scripts #118

Closed
paulantoine2 opened this issue Oct 13, 2021 · 5 comments
Closed

Allow multiple preload scripts #118

paulantoine2 opened this issue Oct 13, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@paulantoine2
Copy link

Is your feature request related to a problem? Please describe.

My application contain 2 BrowserWindows that need 2 different preload scripts, unfortunately, only app/api/preload.ts is bundled in build commands.

Describe the solution you'd like

Select all files in a folder or allow a configuration to declare preload files in workspace.json
Like

"preload": ["apps/desktop/src/app/api/preload.ts", ...]

Describe alternatives you've considered

I added a custom wepack config for the build command :

module.exports = (config) => {
  config.entry = {
    ...config.entry,
    scrapping: 'apps/desktop/src/app/api/other_preload.ts',
  };
  return config;
};

But I can't find an alternative for the make command.

@paulantoine2 paulantoine2 added the enhancement New feature or request label Oct 13, 2021
bennymeg added a commit that referenced this issue Oct 18, 2021
preload script scope should be determined as such:
preload.scope.ts
@bennymeg
Copy link
Owner

Done.
Will be added to the next minor release.

@EchopixUser
Copy link

Does the fix mean the other preload scripts must be named preload.<anything>.ts? I am having troubles getting this to work on v11.4.0. The ts file is not compiled to js and bundled in the dist at all.

@loicbtd
Copy link

loicbtd commented Nov 8, 2021

Does the fix mean the other preload scripts must be named preload.<anything>.ts? I am having troubles getting this to work on v11.4.0. The ts file is not compiled to js and bundled in the dist at all.

Same behavior on my project. Should we do something special to include multiple api/preload.*.ts to the build ?

(I updated the package from v11.1.3 to v11.4.0 to get this feature)

Thanks in advance.

@bennymeg
Copy link
Owner

bennymeg commented Nov 8, 2021

Does the fix mean the other preload scripts must be named preload.{anything}.ts?

Yes.

Should we do something special to include multiple api/preload.*.ts to the build ?

Create a custom webpack configuration file like @paulantoine2 suggested:

module.exports = (config) => {
  config.entry = {
    ...config.entry,
    other_preload: 'apps/desktop/src/app/api/preload.other.ts',
  };
  return config;
};

@bennymeg
Copy link
Owner

I think I did not made a good decision about the preload script naming.
I'm thinking about making a breaking change on v12 to use the following schema:
<anything>.preload.ts seems like a better naming convention.

bennymeg added a commit that referenced this issue Nov 22, 2021
preload script scope should be determined as such:
preload.scope.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants