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

Adding Electron Support #433

Merged
merged 2 commits into from
Sep 10, 2020
Merged

Adding Electron Support #433

merged 2 commits into from
Sep 10, 2020

Conversation

rorticus
Copy link
Contributor

@rorticus rorticus commented Sep 4, 2020

Type: feature

The following has been addressed in the PR:

  • There is a related issue
  • All code has been formatted with prettier
  • Unit or Functional tests are included in the PR
  • schema.json has been updated appopriately

Description:

Adding Electron target. This is largely based on https://github.com/matt-gadd/cli-build-app/tree/electron-support.

Resolves #356

return compiler;
// for some reason the MultiCompiler type doesn't include hooks, even though they are clearly defined on the
// object coming back.
interface MultiCompilerWithHooks extends webpack.MultiCompiler {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to do this?

const onDemandBtr = new OnDemandBtr({
buildTimeRenderOptions: btrOptions,
scope: libraryName,
base,
compiler,
entries: config.entry ? Object.keys(config.entry) : [],
compiler: compiler.compilers[0],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to pass in electron compiler to BTR. Realistically, probably no reason to pass anything to BTR in this case...

src/main.ts Outdated
}

if (args.target === 'electron') {
args.base = `.${args.base}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're using electron, the base path can't be absolute and must be relative.

@@ -119,6 +119,7 @@
"css-loader": "1.0.1",
"css-url-relative-plugin": "1.0.0",
"cssnano": "4.1.7",
"electron": "10.1.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding electron as a dep here so you dont need to install it separately on every app. In the future, we'll look into how to conditionally install deps like puppetteer and electron.

@@ -24,7 +24,7 @@ function webpackConfig(args: any): webpack.Configuration {
const experimental = args.experimental || {};
const isExperimentalSpeed = !!experimental.speed;
const singleBundle = args.singleBundle || isExperimentalSpeed;
const base = args.base || '/';
const base = args.target === 'electron' ? './' : args.base || '/';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Electron target does not support a base URL

@@ -33,7 +33,7 @@ All rights reserved

function webpackConfig(args: any): webpack.Configuration {
const basePath = process.cwd();
const base = args.base || '/';
const base = args.target === 'electron' ? './' : args.base || '/';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Electron target does not support a base URL

@rorticus rorticus marked this pull request as ready for review September 9, 2020 16:33
@rorticus rorticus changed the title Electron Adding Electron Support Sep 9, 2020
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

Successfully merging this pull request may close these issues.

Add electron as a target?
2 participants