Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
electron-webpack
Advanced tools
Configurations and scripts to compile Electron applications.
yarn add webpack electron-webpack --dev
yarn add source-map-support
Yarn is recommended instead of npm.
├─ src
│ ├─ main # main process sources
│ │ └─ index.js
│ ├─ renderer # renderer process sources
│ │ └─ index.js
├─ static # static assets (optional directory)
Index file expected to be named as index.js
or main.js
(.ts
if typescript support installed)
Real project example — electrify.
Fast development without reloading is supported for both main and renderer processes.
You can add following scripts to your package.json
:
{
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
"dist-dir": "yarn dist -- --dir -c.compression=store -c.mac.identity=null"
}
}
yarn dev
Run app in development.yarn compile
Compile app for production. No need to call this script explicitly, only if you want to inspect your compiled app.yarn dist
Build app and package in a distributable format for production.yarn dist-dir
Build app and quickly package in a distributable format for test how does the app work if packed.Webpack documentation is fully applicable. For example, to build for production, specify --env.production
.
node_modules/electron-webpack/webpack.main.config.js
Compile main.node_modules/electron-webpack/webpack.renderer.config.js
Compile renderer.node_modules/electron-webpack/webpack.app.config.js
Compile both main and renderer.node_modules/electron-webpack/webpack.renderer.dll.config.js
Compile DLL bundles for renderer.All renderer dependencies should be in the devDependencies
. e.g. vue
and vue-router
should be in the devDependencies
.
Because Webpack will smartly copy only required files and as result, application size will be minimal
(electron-builder cannot do such filtering, because in general it is not applicable for node modules).
No doubt, files allows you to filter out anything you want, but it is tedious to write and maintain.
The Dll provide means to split bundles in a way that can drastically improve build time performance.
Supported out of the box, specify in the package.json
:
"electronWebpack": {
"renderer": {
"dll": [
"vue",
"iview/dist/styles/iview.css"
]
}
}
Please see White-listing Externals.
electron-webpack
supports setting this option in the package.json
:
"electronWebpack": {
"whiteListedModules": ["dependency-name"]
}
But keep things simple. electron-compile offers you zero-config setup without predefined project structure and simple on the fly runtime transformation. And for simple projects, even direct usage of typescript
/babel
maybe enough (example).
So, if you doubt what to use and no suitable boilerplate — use electron-compile. If need, later you can easily migrate to webpack.
yarn add source-map-support
and that's all.yarn add webpack-build-notifier --dev
and it will automatically enabled for development.Set the DEBUG environment variable to debug what electron-webpack is doing:
DEBUG=electron-webpack:*
FAQs
> Because setting up `webpack` in the `electron` environment shouldn't be difficult.
The npm package electron-webpack receives a total of 1,652 weekly downloads. As such, electron-webpack popularity was classified as popular.
We found that electron-webpack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.