Easily integrate esbuild for your Electron environment.
- Use of
esbuild
for main source code building - Use of
esbuild
orwebpack
for renderer source code building - HMR for
renderer
andmain
processes - Full control of your esbuild configuration
- Full control of your webpack configuration
- Use electron-builder for final package
npx create-electron-esbuild-app --name my-app --package-manager npm --template react-typescript
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
You can use this example for a starter React with TypeScript
Create a electron-esbuild configuration electron-esbuild.config.yaml
mainConfig:
type: esbuild # currently, only esbuild is supported for mainConfig
path: esbuild.main.config.js
src: src/main/main.ts
output: dist/main
rendererConfig:
type: esbuild # 'webpack' for using webpack in renderer, see examples/react-typescript-webpack
path: esbuild.renderer.config.js
html: src/renderer/index.html
src: src/renderer/index.tsx
output: dist/renderer
See example
const path = require('path')
/** @var {Partial<import('esbuild').BuildOptions>} */
module.exports = {
platform: 'node',
entryPoints: [path.resolve('src/main/main.ts')],
bundle: true,
target: 'node14.16.0', // electron version target
loader: {
'.ts': 'ts',
},
}
See example
const path = require('path')
/** @var {Partial<import('esbuild').BuildOptions>} */
module.exports = {
platform: 'browser',
entryPoints: [path.resolve('src/renderer/index.tsx')],
bundle: true,
target: 'chrome89', // electron version target
loader: {
'.ts': 'ts',
'.tsx': 'tsx',
'.css': 'css',
},
}
electron-esbuild is built using node@>=15.12
and npm@>=7.6
. Any pull-request using lower version will be rejected.
npm i
npm run build