electron-quick-start conversion to Scala.js
⚠️ This template is more of an experiment and does not provide the best workflows for developing and building applications. If you need proper dev server implementation with hot reload and module bundler support, please check out following plugins:
- https://github.com/ptrdom/scalajs-esbuild?tab=readme-ov-file#electron-plugin
- https://github.com/ptrdom/scalajs-vite?tab=readme-ov-file#electron
Recommendation is to try out esbuild, because esbuild is faster than vite (rollup).
Requires npm
to be installed in the system.
Run sbt app/electronStart
.
The application is split into five sbt
modules to fit a project structure that works well with Scala.js and the
security guidelines outlined in Electron documentation:
app
- Combines Scala.js output of other modules with additional resources into an Electron application.
- Implements a simple Electron
sbt
plugin with following tasks:app/electronInstall
- copies over resources (index.html
,package.json
,package-lock.json
,styles.css
) to target directory and runsnpm install
.app/electronCompile
- compiles Scala.js modules, copies output to target directory.app/electronStart
- runsnpm start
on target directory.
main
- Contains
main
process of the Electron Process Model. - Can use
Node.js
APIs andCommonJS
modules.
- Contains
preload
- Contains
preload
script. - Can use a polyfilled subset of
Node.js
APIs, so it does useCommonJS
modules, but can onlyrequire
a subset of them.
- Contains
node-shared
- Contains Scala.js facades that can be shared between
main
andpreload
modules.
- Contains Scala.js facades that can be shared between
renderer
- Contains
renderer
process of the Electron Process Model. - Because it used for producing
web content and browsers do not have built-in support
CommonJS
modules, it is built separately as a single bundle.
- Contains
scalaJSStage
setting in main
, preload
and renderer
modules can be used to toggle between FastLinkJS
and FullLinkJS
output.
This software is licensed under the MIT license