1.1.1 • Published 9 months ago
elecpack v1.1.1
elecpack
Install
npm install @anyversion/elecpack
Usage
import { ElecpackBuilder } from '@anyversion/elecpack'
const builder = new ElecpackBuilder({
main: {
context: string // main file context
entry: string // main file entry
electron: string? // electron path, default: require('electron')
checker?: boolean // enable typescript checker, default: true
assets?: string // assets folder, use ElecpackRuntime.getAsset(name) to get asset file
define?: Record<string, any> // define for ElecpackRuntime.define
bytecode?: boolean | 'all' | 'production' | 'development' // enable bytecode, default: false
configFile?: string | string[] // extra webpack config files
skipDefConfigFile?: boolean // skip default webpack config file, default: false
}
preload: {
context: string // preload file context
entry: Record<string, string> // preload file entry, use ElecpackRuntime.getPreload(name) to get preload file
assets?: string | { from: string, to: string } // assets folder
define?: Record<string, any> // define for Webpack define plugin
configFile?: string | string[] // extra webpack config files
bytecode?: WebpackBuilder.Bytecode // enable bytecode, default: false
skipDefConfigFile?: boolean // skip default webpack config file, default: false
}
renderer: {
context: string // renderer file context
entry: Record<string, {
entry: string | string[] // entry file
html: HtmlWebpackPlugin.Options // html-webpack-plugin options
}> // renderer file entry, use ElecpackRuntime.getRenderer(name) to get renderer file or ElecpackRuntime.load({ name: name, hash?: string }, bw)
assets?: string | { from: string, to: string } // assets folder
define?: Record<string, any> // define for Webpack define plugin
configFile?: string | string[] // extra webpack config files
bytecode?: WebpackBuilder.Bytecode // enable bytecode, default: false
skipDefConfigFile?: boolean // skip default webpack config file, default: false
}
// for worker or other files
files?: Record<string, {
context: string
entry: entry
assets?: string | { from: string, to: string }
define?: Record<string, any>
configFile?: string | string[]
bytecode?: WebpackBuilder.Bytecode
skipDefConfigFile?: boolean
}> // use ElecpackRuntime.getFiles(name) to get file
// config for electron-builder
electronBuilder?: {
name: 'elecpack-example', // output name
version: '1.0.0', // output version
configuration?: {
// electron-builder configuration [docs](https://www.electron.build/configuration)
}
}
})
// for development
builder.startDev()
// for production
builder.startBuild()
import ElecpackRuntime from "@anyversion/elecpack/runtime";
const bw = new BrowserWindow({
webPreferences: {
preload: ElecpackRuntime.getPreload("preload"),
},
});
ElecpackRuntime.load({ name: "demo", hash: "hash" }, bw);
console.log(ElecpackRuntime.define["key"]);
new Worker(ElecpackRuntime.getFiles("test-worker"));
1.1.1
9 months ago
1.1.0
9 months ago
1.0.19
9 months ago
1.0.18
10 months ago
1.0.17
10 months ago
1.0.16
10 months ago
1.0.15
10 months ago
1.0.14
10 months ago
1.0.13
10 months ago
1.0.12
10 months ago
1.0.11
10 months ago
1.0.10
10 months ago
1.0.9
10 months ago
1.0.8
10 months ago
1.0.7
10 months ago
1.0.6
10 months ago
1.0.5
10 months ago
1.0.4
10 months ago
1.0.3
10 months ago
1.0.2
10 months ago
1.0.1
10 months ago
1.0.0
10 months ago