0.3.0 • Published 3 months ago

sea-webpack-plugin v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

sea-webpack-plugin

A Webpack plugin for cross-platform generation of Node's SEA (Single executable applications).

📖 Overview

The sea-webpack-plugin is a Webpack plugin designed to create Node’s single executable applications (SEA), offering cross-platform builds (Windows, macOS, and Linux) from any environment. It streamlines the process of bundling Node.js apps into a single file—automatically downloading the required Node.js binary, generating a SEA configuration file, and embedding assets into the final executable.

✨ Features

  • 🏗 Automates SEA Configuration – Generates sea-config.json for packaging Node.js applications.
  • ⬇️ Automatic Node.js Download & Caching – Downloads Node.js for specified platforms and caches it for future use.
  • 📂 Assets Manifest Generation – Embeds assets into the SEA configuration.
  • 🏆 Multi-Platform Support – Supports Windows, macOS, and Linux builds.

🚀 Installation

Install sea-webpack-plugin using npm or yarn:

npm install --save-dev sea-webpack-plugin

or

yarn add --dev sea-webpack-plugin

⚙️ Usage

Basic Webpack Configuration

Add sea-webpack-plugin to your Webpack configuration:

import SeaWebpackPlugin from 'sea-webpack-plugin';
import path from 'path';

export default {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins: [
    new SeaWebpackPlugin({
      name: 'my-app',
      nodeVersion: '23.9.0',
      os: ['win-x64', 'linux-x64', 'darwin-x64', 'darwin-arm64']
      assets: {
        'assets/icon.jpg': { 
          src: 'src/assets/icon.jpg', 
          options: { 
            /*any custom options */
          } 
        },
        'assets/logo.png': { 
          src: 'src/assets/logo.png',
          options: { 
            /*any custom options */
          }
        }
      }
    })
  ]
};

The following apps will be published to the dist folder: my-app-win-x64.exe, my-app-linux-x64, my-app-darwin-x64 and my-app-darwin-arm64.

🔧 Configuration Options

OptionTypeDescription
namestringName of the output executable. Default: name of the output bundle.
nodeVersionstringVersion of Node.js to be used in SEA. This must be the same version as the version being used to build the bundle. Default: 23.9.0.
osstring | string[]Target platform(s) (e.g., win-x64, linux-x64, darwin-x64 - mac on x86, darwin-arm64 - mac on M* chips).
cachePathstringPath to store downloaded Node.js binaries Default: .node_cache in outputPath.
assetsobjectA key-value map of asset files to be embedded. This json is also dumped in to the assets as manifest.json. Any properties passed in the options can be read using this file. To access the assets in the executable, use node functions sea.getAsset, sea.getAssetAsBlob and sea.getRawAsset.

📜 License

This project is licensed under the MIT License.

🤖 AI Assisted Development

sea-webpack-plugin was developed with the help of AI, enabling the team to complete a fully functional release in just 8 hours.

🐳 Using the Docker (Code-Signing)

This plugin ships with a Dockerfile to facilitate cross-plafrom code signing for your SEA builds. You can find this Docker configurations in the code-sign folder:

  1. Build the Docker Image

    cd code-sign
    docker build -t code-signing-docker .
  2. Generate self signed code certificates (Optional) Usage:

    docker run --rm -v <absolute path to the certs folder>:/certs -it code-signing-docker /app/generate_code_sign_cert.sh <country_code> <organization_name> <password> <cert_path>

    Example:

    docker run --rm -v /home/john/certs:/certs -it code-signing-docker /app/generate_code_sign_cert.sh US "RIKSOF Inc" **** /cert/my_app_cert_self
  3. Sign the Windows build Usage:

    docker run --rm -v <absolute path to the certs folder>:/certs <absolute path to the project folder>:/project /app/sign_exe.sh /project/<path_to_exe> /certs/<key_file> <password> <application_name> <url>

    Example:

    docker run --rm -v /home/john/certs:/certs -v /home/john/project:/project -it code-signing-docker /app/sign_exe.sh /project/dist/my-app-win-x64.exe /cert/my_app_cert_self.pfx *** "Application Name" https://www.mydomain.com
  4. Sign the Mac OS build Usage:

    docker run --rm -v <absolute path to the certs folder>:/certs <absolute path to the project folder>:/project /app/sign_macos.sh /project/<executable_path> /certs/<p12/pfx_file> <p12_password> <identifier>

    Example:

    docker run --rm -v /home/john/certs:/certs -v /home/john/project:/project -it code-signing-docker /app/sign_macos.sh /project/dist/my-app-darwin-arm64 /cert/my_app_cert_self_macos.pfx *** com.domain.my-app

This approach ensures your executables are properly signed and trusted across multiple platforms, further streamlining your SEA distribution.


© 2025 RIKSOF, Inc. All rights reserved.

0.3.0

3 months ago

0.2.0

3 months ago

0.1.0

3 months ago