Skip to content

Build NW.js applications for Linux, MacOS and Windows

License

Notifications You must be signed in to change notification settings

zkrige/nw-builder

Repository files navigation

nw-builder

npm Join the chat at https://gitter.im/nwjs/nw-builder

Build NW.js applications for Mac, Windows and Linux.

For version 3, please go to the corresponding branch.

Major Features

  • Get, run or build applications.
  • Integrate FFmpeg community builds
  • Configure executable fields and icons
  • Support downloading from mirrors

Check out the documentation if you wish to give nw-builder a try.

Please note that the documentation assumes you know how to write NW.js applications.

Alternatives

Migration Guide (v3 -> v4)

We are working on making the migration process smoother. If you encounter any issues with the current guide, please open an issue or start a discussion.

Update nw-builder

With npm:

npm update nw-builder@latest

With yarn:

yarn upgrade nw-builder@latest

With pnpm:

pnpm update nw-builder@latest

Update options

Let's take an example of v3 code and migrate it to v4.

const NwBuilder = require("nw-builder");

const nw = new NwBuilder({
  files: ["./nwapp/**/*", "./other/**/*.js"],
  version: "latest",
  flavor: "normal",
  platforms: ["win32", "win64", "osx32", "osx64", "linux32", "linux64"],
  cacheDir: "./cache",
  buildDir: "./build",
  buildType: "versioned",
  forceDownload: true,
  appName: "nwdemo",
  appVersion: "0.1.0",
  argv: "--nw-stderr-logging",
  macCredits: "./nwapp/credits.html",
  macIcns: "./nwapp/mac.icns",
  macPlist: { ... },
  winVersionString: { ... },
  winIco: "./nwapp/win.ico",
  zip: true,
  macZip: false,
  mergeZip: false,
});

nw.build();

Update the import path

-const NwBuilder = require("nw-builder");
+const nwbuild = require("nw-builder");

Replace the NwBuilder initialization with a function

-const nw = new NwBuilder({
+await nwbuild({

The files property has been renamed to srcDir.

-  files: ["./nwapp/**/*", "./other/**/*.js"],
+  srcDir: "./nwapp/**/* ./other/**/*.js",

Add the mode option and remove the now redundant nw.build function call. The build call is made by nwbuild internally.

+  mode: "build",

-nw.build();

The platforms option has been removed and replaced with platform and arch. Notice that one nwbuild function call now creates one build for one platform and one arch only.

-  platforms: ["win32", "win64", "osx32", "osx64", "linux32", "linux64"],
+  platform: "linux", // "osx" for MacOS "win",  for Windows
+  arch: "x64", // "ia32" for 32 bit or "arm64" for arm based 65 bit architectures

The buildDir option has been rename to outDir.

-  buildDir: "./build",
+  outDir: "./build",

The buildType option has been removed.

-  buildType: "versioned",

The forceDownload option has been changed to cache.

-  forceDownload: true,
+  cache: false,

The appName option has been changed to app.name.

-  appName: "nwdemo",
+  app: { name: "nwdemo" },

The appVersion option has been changed to app.version.

-  appVersion: "0.1.0",
+  app: { version: "0.1.0" },

The macCredit option has been removed.

-  macCredits: "./nwapp/credits.html",

The macIcns option has been replaced with icon.

-  macIcns: "./nwapp/mac.icns",
+  icon: "./nwapp/mac.icns",

The macPlist option has been replaced by app.* options. Consult the documentation for valid properties.

-  macPlist: { ... },
+  app: { ... },

The winVersionString option has been replaced with app. Consult the documentation for valid properties.

-  winVersionString: {
-    'CompanyName': 'Some Company',
-    'FileDescription': 'Process Name',
-    'ProductName': 'Some Product',
-    'LegalCopyright': 'Copyright 2017',
-  }
+  app: {
+    company: "Some Company",
+    fileDescription: "Process Name",
+    productName: "Some Product",
+    legalCopyright: "Copyright (c) 2023",
+  }

The winIco option has been replaced by app.icon.

-  winIco: "./nwapp/win.ico",
+  app: { icon: "./nwapp/win.ico" },

The macZip option has been removed.

-  macZip: false,

The mergeZip option has been removed.

-  mergeZip: false,

The final code should look like this.

const { nwbuild } = require("nw-builder");

await nwbuild({
  srcDir: "./nwapp/**/* ./other/**/*.js",
  mode: "build",
  version: "latest",
  flavor: "normal",
  platform: "linux",
  arch: "x64",
  outDir: "./build",
  cache: false,
  app: { ... },
});

About

Build NW.js applications for Linux, MacOS and Windows

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.4%
  • Other 1.6%