bin.js
ee-bin: v5.0.0
ee-core: v5.0.0
Various commands and tool configurations for the development environment.
File Location
bash
./cmd/bin.jsConfiguration Guide
javascript
/**
* ee-bin configuration
* Only applicable to development environment
*/
module.exports = {
/**
* Command: ee-bin dev
*
* Development mode service configuration
*/
dev: {
// frontend: frontend service
// Description: This configuration means entering the frontend directory and executing npm run dev
// The running service is http://localhost:8080
// If the protocol property is 'file://', no command will be executed; the project directly loads the indexPath file.
frontend: {
directory: './frontend', // frontend directory
cmd: 'npm', // command
args: ['run', 'dev'], // arguments
protocol: 'http://', // protocol: 'http://' 'file://'
hostname: 'localhost', // hostname
port: 8080, // port
indexPath: 'index.html' // effective when 'file://' protocol, entry file
force: false, // force load frontend service
sync: false, // (non-daemon process only) whether to execute commands serially
},
// electron: main process service
// Description: This configuration means executing electron . --env=local in the root directory
electron: {
directory: './',
cmd: 'electron',
args: ['.', '--env=local'], // --env: local|prod; '--color=always' console color
// Whether to watch for file changes; if watching, the command will re-execute on each file change
watch: true,
delay: 0, // Delayed startup time, unit: milliseconds
loadingPage: '/public/html/loading.html', // If frontend startup takes too long, load a loading page first
sync: false, // (non-daemon process only) whether to execute commands serially
}
},
/**
* Build
* Command: ee-bin build
* Description: Used to build executable programs, frontend, main process, go, or custom commands
*
* Executable program
* Example: ee-bin build --cmds=win64 build exe
*
* Frontend
* Example: ee-bin build --cmds=frontend (build frontend dist resources)
*
* Main process ./electron
* Example: ee-bin build --cmds=electron (build main process ./electron directory code)
*
* Custom
* Example: ee-bin build --cmds=go_w (build go windows platform program)
* Example: ee-bin build --cmds=go_m (build go macos platform program)
* Example: ee-bin build --cmds=go_l (build go linux platform program)
*/
build: {
// Build frontend code, configure based on actual frontend project
frontend: {
directory: './frontend',
cmd: 'npm',
args: ['run', 'build'],
},
// Build main process code ./electron
electron: {
/**
* Build method
* 'bundle' - Bundle into single file with esbuild (default)
* 'copy' - Copy electron/ directory verbatim, no bundling (not recommended)
*/
bundleType: 'bundle',
/**
* User-defined external packages
* Framework built-in: ee-core, ee-bin, electron, better-sqlite3, proxy-agent, pino-roll, pino-pretty
* If your project imports packages that cannot be bundled (e.g. native modules), add the package name here
* Example: external: ['sharp', 'node-gyp']
*/
external: [],
/**
* Source map configuration (for breakpoint debugging)
* true | 'inline' - Source embedded in main.js, DevTools/VS Code out-of-the-box (recommended for dev)
* 'external' - Generate main.js.map file, can be separately deleted in production
* false - No sourcemap generated (default: dev→inline, prod→off)
*/
sourcemap: false,
/**
* Minify code
* true - Minify whitespace, identifiers, syntax
* false - No minification (default)
*/
minify: false,
/**
* Remove console and debugger statements (recommended for production)
* Example: drop: ['console', 'debugger']
*/
drop: [],
/**
* Preserve original function/class names during minification (helpful for error tracing)
* true - Preserve names (recommended when minifying)
* false - Do not preserve (default)
*/
keepNames: false,
/**
* Third-party library license comment handling
* 'inline' - Comments inlined into each file
* 'eof' - Comments moved to file end
* 'none' - Remove all comments (default)
*/
legalComments: 'none',
/**
* Custom global constants (compile-time replacement)
* Example: define: { 'process.env.MY_VERSION': '"1.0.0"' }
*/
define: {},
/**
* Extra copy of directories or files under electron/ to output directory (not bundled into main.js, preserves directory structure)
* Framework built-in copy: jobs/, preload/bridge.js (cannot be removed)
* Smart handling: .ts/.js/.mts/.cts/.tsx/.jsx source code is compiled into Node-loadable CJS .js
* (bundle:false, relative imports and ee-core/* still retained as runtime require);
* other files (e.g. .json, images) are copied verbatim
* Applicable scenarios: static assets, or source code not bundled into main.js but needed at runtime via require()/child_process.fork()
* Directory example: copy: ['assets'] → electron/assets/ → public/electron/assets/ (verbatim copy)
* copy: ['workers'] → compile electron/workers/ → public/electron/workers/
* File example: copy: ['data/db.json'] → electron/data/db.json → public/electron/data/db.json (verbatim copy)
* copy: ['scripts/task.ts']→ compile electron/scripts/task.ts → public/electron/scripts/task.js
*/
copy: [],
/**
* Output format
* 'cjs' - CommonJS (recommended, most stable for Electron main process)
* 'esm' - ES Module (requires business code ESM compatibility, e.g. controller/service registry require() calls)
* Default: 'cjs'
*/
format: 'cjs',
},
// Executable programs, can be extended based on electron-builder official docs
// Build 32-bit exe
win32: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder.json', '-w=nsis', '--ia32'],
},
// Build 64-bit exe
win64: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder.json', '-w=nsis', '--x64'],
},
// Build portable package
win_e: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder.json', '-w=portable', '--x64'],
},
// Build compressed archive
win_7z: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder.json', '-w=7z', '--x64'],
},
// Build macOS Intel chip dmg
mac: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder-mac.json', '-m'],
},
// Build macOS M-series chip dmg
mac_arm64: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder-mac-arm64.json', '-m', '--arm64'],
},
// Build exe
linux: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder-linux.json', '-l=deb', '--x64'],
},
// Build exe
linux_arm64: {
cmd: 'electron-builder',
directory: './',
args: ['--config=./cmd/builder-linux.json', '-l=deb', '--arm64'],
},
// (Optional) go
go_w: {
directory: './go',
cmd: 'go',
args: ['build', '-o=../build/extraResources/goapp.exe'],
},
go_m: {
directory: './go',
cmd: 'go',
args: ['build', '-o=../build/extraResources/goapp'],
},
go_l: {
directory: './go',
cmd: 'go',
args: ['build', '-o=../build/extraResources/goapp'],
}
// (Optional) python
python: {
directory: './python',
cmd: 'python',
args: ['./setup.py', 'build'],
},
},
/**
* Move Resources
*
* Command: ee-bin move
* Description: Move frontend, go, config and other static resources to specified directories for production use. Supports files and directories.
*
* Example 1: ee-bin move --flag=frontend_dist (move frontend dist resources)
* Example 2: ee-bin move --flag=go_static,go_config,go_package,go_images (move go resources)
*/
move: {
frontend_dist: {
src: './frontend/dist',
dest: './public/dist'
},
go_static: {
src: './frontend/dist',
dest: './go/public/dist'
},
go_config: {
src: './go/config',
dest: './go/public/config'
},
go_package: {
src: './package.json',
dest: './go/public/package.json'
},
go_images: {
src: './public/images',
dest: './go/public/images'
},
python_dist: {
src: './python/dist',
dest: './build/extraResources/py'
},
},
/**
* Staging Mode (prod)
* Command: ee-bin start
* Description: This configuration means executing electron . --env=prod in the root directory
*/
start: {
directory: './',
cmd: 'electron',
args: ['.', '--env=prod']
},
/**
* Encryption
* Command: ee-bin encrypt
* Description: Multiple encryption features, supports encryption of main process and frontend code, protecting your source code security.
*/
encrypt: {
frontend: {
// Supported: none - no encryption, confusion - compress & obfuscate encryption
type: 'none',
// File matching
// ! prefix means filter/exclude
files: [
'./public/dist/**/*.(js|json)',
],
// File extensions to encrypt, only js supported
fileExt: ['.js'],
cleanFiles: ['./public/dist'],
// Obfuscation encryption configuration
confusionOptions: {
// Compress to single line
compact: true,
// Remove string literals and place them in a special array
stringArray: true,
// Encode all string literals in stringArray, values: 'none' | 'base64' | 'rc4'
stringArrayEncoding: ['none'],
// Inject dead code, note: affects performance
deadCodeInjection: false,
// Dead code ratio
deadCodeInjectionThreshold: 0.1,
// All call arguments can be extracted into different objects
stringArrayCallsTransform: true,
// Numbers to expressions
numbersToExpressions: true,
target: 'browser',
},
// Suppress javascript-obfuscator promotional banner during obfuscation
silent: true,
},
electron: {
// none - no encryption
// confusion - compress & obfuscate encryption
// bytecode - bytecode encryption
// strict - obfuscate first, then bytecode encryption
type: 'confusion',
files: [
'./public/electron/**/*.(js|json)',
],
fileExt: ['.js'],
cleanFiles: ['./public/electron'],
// bridge.js is a BrowserWindow preload script and must remain readable,
// so it is specifically listed to use obfuscation encryption instead of bytecode encryption.
specificFiles: ['./public/electron/preload/bridge.js'],
// Electron package entry must remain main.js; in bytecode/strict mode,
// it becomes a tiny bytenode loader shell that requires main.jsc.
entryFiles: ['./public/electron/main.js'],
encryptDir: './',
// Hide javascript-obfuscator promotional banner during obfuscation encryption
silent: false,
confusionOptions: {
compact: true,
stringArray: true,
stringArrayEncoding: ['rc4'],
deadCodeInjection: false,
stringArrayCallsTransform: true,
numbersToExpressions: true,
target: 'node',
},
bytecodeOptions: {
electron: true,
},
}
},
/**
* Execute Custom Commands
* ee-bin exec
*/
exec: {
node_v: {
directory: './',
cmd: 'node',
args: ['-v'],
sync: false, // (non-daemon process only) whether to execute commands synchronously
},
// Debug separately, air provides go hot reload
go: {
directory: './go',
cmd: 'air',
args: ['-c=config/.air.toml' ],
},
// Windows debug separately, air provides go hot reload
go_w: {
directory: './go',
cmd: 'air',
args: ['-c=config/.air.windows.toml' ],
},
// Debug separately, start go in basic mode
go2: {
directory: './go',
cmd: 'go',
args: ['run', './main.go', '--env=dev','--basedir=../', '--port=7073'],
},
python: {
directory: './python',
cmd: 'python',
args: ['./main.py', '--port=7074'],
stdio: "inherit", // ignore
},
},
};