Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-esbuild

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-esbuild

Use esbuild with Electron for blazing fast compilation

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111
increased by1133.33%
Maintainers
1
Weekly downloads
 
Created
Source

electron-esbuild

Easily integrate esbuild for your Electron environment.

Features

  • Use of esbuild for main source code building
  • Use of webpack for renderer source code building
  • HMR for renderer and main processes
  • Full control of your webpack configuration
  • Full control of your esbuild configuration
  • Use electron-builder for final package

Use

npm i -D electron-esbuild

Start a development build (example)

npx electron-esbuild dev

Create a build (example)

npx electron-esbuild build
npx electron-esbuild build --no-clean # do not clean output before build

Package the app (example)

npx electron-builder -p=never

Quick start

You can use this example for a starter React with TypeScript

Configuration

Create a electron-esbuild configuration electron-esbuild.config.yaml

# paths relative to current working directory

esbuildMainConfig: esbuild.config.js # path to your esbuild configuration
webpackRendererConfig: webpack.config.js # path to your webpack configuration

Main esbuild config

See example

// esbuild.config.js
const path = require('path')

/**
 * @param {Partial<import('esbuild').BuildOptions>} merge configuration added by electron-esbuild
 *
 * @return {import('esbuild').BuildOptions}
 */
module.exports = (merge) => { // electron-esbuild expects a function from esbuild configuration
  // merge object contains production/development configuration added by electron-esbuild
  // electron-esbuild overrides NODE_ENV when using `dev` or `build` command
  const isProduction = process.env.NODE_ENV === 'production'

  return {
    platform: 'node',
    entryPoints: [path.resolve('src/main/main.ts')], // Path to your main file
    bundle: true,
    target: 'node12.18.4', // electron version target
    loader: {
      '.ts': 'ts', // Default loader for TypeScript project
    },
    sourcemap: false,
    define: {
      'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
    },
    ...merge,
  }
}

Renderer webpack configuration

See example

This example use HMR/Hot reload in the renderer process in development!

Keywords

FAQs

Package last updated on 05 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc