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

Issue with config.target in angular.webpack.js during simultaneous "electron" and "web" development #808

Open
distributev opened this issue Apr 5, 2024 · 1 comment

Comments

@distributev
Copy link

I'm encountering an issue with the config.target in the angular.webpack.js file when running the

npm run start,

script which is intended for simultaneous "electron" and "web" in development (``````"start": "npm-run-all -p electron:serve ng:serve"```)

To illustrate the issue, I added the following console.log statement at the end of the angular.webpack.js file:

console.log(`config.target = ${config.target}`);
return config;

I expected this log statement to be executed twice, once for electron-renderer and once for web, as the

npm run start

script is supposed to start both the Electron and Web apps.

"start": "npm-run-all -p electron:serve ng:serve"

However, the log statement is only executed once, and config.target is always web.

For the simple app present with this boilerplate both "electron" and "web" apps start and work fine when we do
npm run start but for a more complex app where more electron deps are involved it will become a real problem that

config.target is always web. in the angular.webpack.js script.

This behavior prevents me from adding custom angular.webpack.js logic based on the config.target value, such as:

if (config.target == "electron-renderer") require("electron");

This issue seems to be related to

#721

The npm run start script, which is defined as

"start": "npm-run-all -p electron:serve ng:serve",

is intended for development and works fine for simple apps. However, for more complex apps with additional Electron dependencies, the issue becomes apparent.

I'm looking for a way to correctly set and detect the config.target value during development, so I can develop an app that works both in Electron and a web browser.

Any guidance would be appreciated.

@distributev
Copy link
Author

"start": "npm-run-all -p electron:serve ng:serve"

starts a single server on port 4200 from which both the "electron" and "web" are served. The single server uses the "web" build (electron should use a different build not the "web"!)

this is another way of explaining the same issue.

"electron" should start its own server/build and "web" should start is own server/build on different ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant