- Print
- DarkLight
- PDF
Develop your Desktop App
- Print
- DarkLight
- PDF
Developing Rocket.Chat desktop apps require using TypeScript 4. Consult the TypeScript 4 release handbook to stay informed and updated.
The build pipeline
The foundation of the build process relies on the rollup bundler, which is responsible for compiling and integrating all components. The codebase has three entry files:
src/main.ts
: The script runs during the main electron process, orchestrating the whole application.src/rootWindow.ts
: The script that renders the UI of the root window, which serves as the app's main window;src/preload.ts
: The script runs in a privileged mode to connect the app and the webviews rendering Rocket.Chat's web client.
Adding Node.js modules
When extending the app's functionalities with modules, it's crucial to distinguish between modules required as dependencies
and those marked as devDependencies
in the package.json
file. Similar to any other project relying on packages, only modules listed in dependencies
will be included in the final distributable app.
Servers
Default servers
To establish automatic connections when the application launches, you can define default servers. This involves creating a servers.json
file in the root directory of the project. This configuration ensures that the server list sidebar is automatically populated when the app launches or when all servers are deleted.
The servers.json
file syntax is as follows:
{
"Demo Rocket Chat": "https://demo.rocket.chat",
"Open Rocket Chat": "https://open.rocket.chat",
"Awesome Rocket Chat": "https://awesome.rocket.chat"
}
Pre-release server configuration
You have the option to bundle a servers.json
file with the installation package. This file should be located at the root level of the project application in the same directory as the package.json
file. When the file is located, the initial "Connect to server" screen won't appear. Instead, the app will try to connect to the first server listed in the array. Once connected, the user will be taken directly to the login screen.
Note that the
servers.json
file will only be checked if no other servers have been added previously. Even if you uninstall the app without removing previous preferences, this check will not be triggered again.
Post-install server configuration
If you cannot or prefer not to include the file within the app bundle, an alternative approach is available. You can generate a servers.json
file in the user preferences folder, which will override the packaged one. This file should be positioned in any of the directories outlined below, depending on your operating system:
~\Users\<username>\AppData\Roaming\Rocket.Chat\
~\Program Files\Rocket.Chat\Resources\
~/Users/<username>/Library/Application Support/Rocket.Chat/
~/Applications/Rocket.Chat.app/Contents/Resources/
/home/<username>/.config/Rocket.Chat/
/opt/Rocket.Chat/resources/
Unit tests
We use Jest testing framework with the Jest electron runner. It searches for all files in the src/
directory that matches the glob pattern *.(spec|test).{js,ts,tsx}
and performs tests on them.
Run this command to execute tests on your changes:
yarn test
Making a release
To bundle your application into an installer, use the following command:
yarn release
This command initiates the packaging procedure for the specific operating system you're currently using. Once completed, the resulting output file is prepared for distribution and can be located in the dist/
directory.
It's important to note that electron-builder manages all packaging operations, and it offers many customization possibilities.
If you encounter an error or unexpected behavior, you can follow the debugging options we have documented.