Building for Production
Relevant source files
The following files were used as context for generating this wiki page:Building the Scripty application for production involves a multi-step process that combines the Vite-based React frontend with the Rust-based Tauri backend. The process is orchestrated by the Tauri CLI, which first triggers the frontend build and then compiles and bundles the Rust application, embedding the web assets into a single, distributable executable for various platforms.
The final output is a native desktop application that includes an integrated auto-updater. This updater periodically checks a specified URL for new releases, downloads them in the background, and prompts the user to relaunch the application to complete the update.
Build Orchestration
The entire production build process is managed by Tauri, using configurations defined in tauri.conf.json and package.json. The primary command to initiate a build is tauri build.
Sources: package.json:10, tauri.conf.json:9-13
Build Flow
The following diagram illustrates the high-level flow when tauri build is executed.
This diagram shows the sequential process starting from the Tauri command, running the frontend build script, compiling the Rust code, and finally bundling everything into a distributable application with updater support.
Sources: package.json:8, tauri.conf.json:11-12
Key Configuration Files
The build process relies on several key configuration files that define how the frontend and backend are built and bundled.
This diagram shows the relationship between the main configuration files for the frontend (Vite), backend (Cargo), and the central Tauri configuration that orchestrates the build.
Sources: package.json, vite.config.js, src-tauri/Cargo.toml, tauri.conf.json
Frontend Build
The frontend is a React application built using Vite. The build process is defined by the build script in package.json.
Sources: package.json:8, vite.config.js
Build Scripts
The package.json file contains the scripts for development, building, and running Tauri commands.
| Script | Command | Description |
|---|---|---|
dev | vite | Starts the Vite development server. |
build | vite build | Compiles the React frontend for production. |
tauri | tauri | A wrapper for executing Tauri CLI commands. |
Sources: package.json:6-10
Vite Configuration
The vite.config.js file specifies how the frontend assets are compiled. For production, the most relevant part is the build configuration.
// vite.config.js:10-12
build: {
target: 'esnext'
},
This configuration ensures the JavaScript output is compiled to the esnext target, which supports modern JavaScript features. The output of this build process is placed in the dist directory, as specified in tauri.conf.json.
Sources: vite.config.js:10-12, tauri.conf.json:12
Backend Build
The backend is a Rust application using the Tauri framework. The build is managed by Cargo, Rust's package manager, based on Cargo.toml.
Sources: src-tauri/Cargo.toml, src-tauri/build.rs, src-tauri/src/main.rs
Cargo Configuration
src-tauri/Cargo.toml defines the project's metadata and dependencies.
- Package Name:
scripty - Version:
0.9.1 - Build Dependency:
tauri-buildis used to run the build script. - Dependencies: Includes
tauriand various plugins liketauri-plugin-updater,tauri-plugin-fs, andtauri-plugin-dialog.
For Windows release builds, a specific attribute is set in src-tauri/src/main.rs to prevent a console window from appearing alongside the application window.
// src-tauri/src/main.rs:2
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
Sources: src-tauri/Cargo.toml:2-27, src-tauri/src/main.rs:2
Build Script
The src-tauri/build.rs file contains a simple script that triggers the standard Tauri build process.
// src-tauri/build.rs:1-3
fn main() {
tauri_build::build()
}
Sources: src-tauri/build.rs:1-3
Application Bundling
After the frontend and backend are built, Tauri bundles them into a final application. The tauri.conf.json file contains all the settings for this process.
Sources: tauri.conf.json:28-46
Bundle Configuration
The bundle section defines the output of the build process.
| Property | Value | Description |
|---|---|---|
active | true | Enables the bundler. |
targets | "all" | Specifies to build for all possible targets on the current platform. |
icon | ["icons/32x32.png", ...] | A list of paths to the application icons for different platforms/sizes. |
createUpdaterArtifacts | true | Instructs Tauri to generate update-specific files (signatures, manifests). |
Sources: tauri.conf.json:29-43
Application Identifier
The application is identified by a unique string, which is crucial for updates and OS integration.
- Product Name:
(S)cripty - Version:
0.9.1 - Identifier:
com.scripty.app
Sources: tauri.conf.json:3-5
Auto-Updater
Scripty includes a built-in auto-updater, which is configured in tauri.conf.json and initialized in the application's Rust code.
Updater Configuration
The updater is enabled and configured within the plugins section of tauri.conf.json.
// tauri.conf.json:48-54
"updater": {
"active": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQxRURENUVBNzg3NzAzMzUKUldRMUEzZDQ2dFh0UVl3VGRodXNtRmNWV2VFUkZpWWo0TWpnZXVMZ05XLzhYb0hkU1hPUng5NEYK",
"endpoints": [
"https://github.com/SemtexHR/ScriptTool/releases/latest/download/latest.json%22
]
}
active:trueenables the updater plugin.pubkey: A public key used to verify the signature of the update artifacts, ensuring they are authentic.endpoints: A list of URLs where the application will look for thelatest.jsonmanifest file that describes available updates.
Sources: tauri.conf.json:47-55
Updater Implementation
The updater is initialized in src-tauri/src/lib.rs when the application starts. The frontend code in src/App.jsx actively checks for updates on startup.
The update check and installation flow is as follows:
This sequence shows the frontend initiating an update check. If an update is found, it's downloaded and installed, and finally, the application is relaunched to apply the update.
Sources: src/App.jsx:15-41, src-tauri/src/lib.rs:64