mcpField
C
configuring-tauri-apps

configuring-tauri-apps

github.com/dchuk開発36173 回インストール40 週間前に更新
リポジトリ

configuring-tauri-apps について

Tauri v2 アプリの設定を扱う開発者向けリファレンスです。主要な設定ファイルや、プラットフォーム別・環境別の上書き方法、一般的な項目を説明します。

主な機能

  1. 01Tauri 設定ファイルの役割
  2. 02ウィンドウとセキュリティの設定
  3. 03プラットフォーム別の上書き
  4. 04開発・リリース環境の設定
  5. 05Cargo と package.json の設定
  6. 06設定の検証

活用シーン

  1. 01ウィンドウ動作とアプリ情報の設定
  2. 02開発用と本番用設定の分離
  3. 03プラットフォームごとの設定変更
  4. 04設定とビルド環境の確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/dchuk/claude-code-tauri-skills --skill configuring-tauri-apps

インストール後、Claude Code で/configuring-tauri-appsを入力して読み込まれたか確認します。

詳細

Tauri 設定ファイル

Tauri v2 アプリケーションでは、アプリケーションの動作、依存関係、ビルドプロセスを管理するために、主に3つの設定ファイルを使用します。

設定ファイルの概要

ファイル用途形式
tauri.conf.jsonTauri 固有の設定JSON、JSON5、または TOML
Cargo.tomlRust の依存関係とメタデータTOML
package.jsonフロントエンドの依存関係とスクリプトJSON

tauri.conf.json

src-tauri/ にあるメインの設定ファイルです。アプリケーションのメタデータ、ウィンドウの動作、バンドルオプション、プラグイン設定を定義します。

サポートされている形式
  • JSON(デフォルト):tauri.conf.json
  • JSON5:tauri.conf.json5(config-json5 Cargo 機能が必要です)
  • TOML:Tauri.toml(config-toml Cargo 機能が必要です)
完全な設定構造
{
  "$schema": "https://schema.tauri.app/config/2",
  "productName": "MyApp",
  "version": "1.0.0",
  "identifier": "com.company.myapp",
  "mainBinaryName": "my-app",
  "build": {
    "devUrl": "http://localhost:3000",
    "frontendDist": "../dist",
    "beforeDevCommand": "npm run dev",
    "beforeBuildCommand": "npm run build",
    "features": ["custom-feature"],
    "removeUnusedCommands": true
  },
  "app": {
    "withGlobalTauri": false,
    "macOSPrivateApi": false,
    "windows": [
      {
        "title": "My Application",
        "width": 1200,
        "height": 800,
        "minWidth": 800,
        "minHeight": 600,
        "resizable": true,
        "fullscreen": false,
        "center": true,
        "visible": true,
        "decorations": true,
        "transparent": false,
        "alwaysOnTop": false,
        "focus": true,
        "url": "index.html"
      }
    ],
    "security": {
      "capabilities": [],
      "assetProtocol": {
        "enable": true,
        "scope": ["$APPDATA/**"]
      },
      "pattern": { "use": "brownfield" },
      "freezePrototype": false
    },
    "trayIcon": {
      "id": "main-tray",
      "iconPath": "icons/tray.png",
      "iconAsTemplate": true
    }
  },
  "bundle": {
    "active": true,
    "targets": "all",
    "icon": ["icons/32x32.png", "icons/128x128.png", "icons/icon.icns", "icons/icon.ico"],
    "resources": ["assets/**/*"],
    "copyright": "Copyright 2024",
    "category": "Utility",
    "shortDescription": "A short app description",
    "longDescription": "A longer description",
    "licenseFile": "../LICENSE",
    "windows": {
      "certificateThumbprint": null,
      "timestampUrl": "http://timestamp.digicert.com",
      "nsis": { "license": "../LICENSE", "installerIcon": "icons/icon.ico", "installMode": "currentUser" }
    },
    "macOS": {
      "minimumSystemVersion": "10.13",
      "signingIdentity": null,
      "dmg": { "appPosition": { "x": 180, "y": 170 }, "applicationFolderPosition": { "x": 480, "y": 170 } }
    },
    "linux": {
      "appimage": { "bundleMediaFramework": false },
      "deb": { "depends": ["libwebkit2gtk-4.1-0"] },
      "rpm": { "depends": ["webkit2gtk4.1"] }
    },
    "android": { "minSdkVersion": 24 },
    "iOS": { "minimumSystemVersion": "13.0" }
  },
  "plugins": {
    "updater": {
      "pubkey": "YOUR_PUBLIC_KEY",
      "endpoints": ["https://releases.example.com/{{target}}/{{arch}}/{{current_version}}"]
    }
  }
}
ルートレベルのフィールド
フィールド型必須説明
productNamestringいいえアプリケーションの表示名
versionstringいいえSemver バージョン、または package.json へのパス
identifierstringはい逆ドメイン形式の識別子(例:com.tauri.example)
mainBinaryNamestringいいえメインバイナリのファイル名を上書きします
ビルド設定フィールド
フィールド型説明
devUrlstringホットリロード用の開発サーバー URL
frontendDiststringビルド済みフロントエンドアセットのパス、またはリモート URL
beforeDevCommandstringtauri dev の前に実行するスクリプト
beforeBuildCommandstringtauri build の前に実行するスクリプト
featuresstring[]ビルド時に有効にする Cargo 機能
removeUnusedCommandsboolean未使用のプラグインコマンドをバイナリから削除します
ウィンドウ設定オプション
フィールド型デフォルト説明
titlestring"Tauri"ウィンドウタイトル
width / heightnumber800 / 600ウィンドウのピクセル単位のサイズ
minWidth / minHeightnumber-最小サイズ
maxWidth / maxHeightnumber-最大サイズ
x / ynumber-ウィンドウの位置
resizablebooleantrueウィンドウのサイズ変更を許可します
fullscreenbooleanfalse全画面表示で起動します
centerbooleanfalseウィンドウを画面中央に配置します
visiblebooleantrue起動時のウィンドウの表示状態
decorationsbooleantrueウィンドウの装飾を表示します
transparentbooleanfalseウィンドウの透明化を有効にします
alwaysOnTopbooleanfalseウィンドウを常に最前面に表示します
urlstring"index.html"最初に読み込む URL
セキュリティ設定
フィールド型説明
capabilitiesstring[]アプリケーションの権限機能
assetProtocol.enablebooleanカスタムアセットプロトコルを有効にします
assetProtocol.scopestring[]アセットプロトコルで許可するパス
pattern.usestringセキュリティパターン(デフォルトは"brownfield")
freezePrototypebooleanプロトタイプの変更を防止します
プラットフォーム別のバンドルターゲット
プラットフォームターゲット
Windowsnsis、msi
macOSapp、dmg
Linuxappimage、deb、rpm
Androidapk、aab
iOSapp

プラットフォーム固有の設定

JSON Merge Patch(RFC 7396)を使用して基本設定を上書きする、プラットフォーム固有のファイルを作成します。

プラットフォームファイル名
Linuxtauri.linux.conf.json
Windowstauri.windows.conf.json
macOStauri.macos.conf.json
Androidtauri.android.conf.json
iOStauri.ios.conf.json

src-tauri/tauri.windows.conf.json の例:

{
  "app": {
    "windows": [{ "title": "My App - Windows Edition" }]
  },
  "bundle": {
    "windows": { "nsis": { "installMode": "perMachine" } }
  }
}

src-tauri/tauri.macos.conf.json の例:

{
  "app": { "macOSPrivateApi": true },
  "bundle": {
    "macOS": { "minimumSystemVersion": "11.0", "entitlements": "entitlements.plist" }
  }
}

CLI 設定の上書き

# Development with custom config
tauri dev --config src-tauri/tauri.dev.conf.json

# Build with beta configuration
tauri build --config src-tauri/tauri.beta.conf.json

# Inline configuration override
tauri build --config '{"bundle":{"identifier":"com.company.myapp.beta"}}'

Cargo.toml の設定

src-tauri/Cargo.toml にあり、Rust の依存関係を管理します。

[package]
name = "my-app"
version = "1.0.0"
edition = "2021"

[build-dependencies]
tauri-build = { version = "2.0", features = [] }

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri = { version = "2.0", features = [] }
tauri-plugin-shell = "2.0"
tauri-plugin-opener = "2.0"

[features]
default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
Tauri の一般的な機能
[dependencies]
tauri = { version = "2.0", features = [
  "config-json5",      # Enable JSON5 config format
  "config-toml",       # Enable TOML config format
  "devtools",          # Enable WebView devtools
  "macos-private-api", # Enable macOS private APIs
  "tray-icon",         # Enable system tray support
  "image-png",         # PNG image support
  "image-ico",         # ICO image support
  "protocol-asset"     # Custom asset protocol
] }
バージョン管理
tauri = { version = "2.0" }       # Semver-compatible (recommended)
tauri = { version = "=2.0.0" }    # Exact version
tauri = { version = "~2.0.0" }    # Patch updates only

package.json との統合

{
  "name": "my-tauri-app",
  "version": "1.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "tauri": "tauri"
  },
  "dependencies": { "@tauri-apps/api": "^2.0.0" },
  "devDependencies": { "@tauri-apps/cli": "^2.0.0" }
}

環境固有の設定

開発環境(src-tauri/tauri.dev.conf.json)
{
  "build": { "devUrl": "http://localhost:5173" },
  "app": {
    "withGlobalTauri": true,
    "windows": [{ "title": "My App [DEV]" }]
  }
}
本番環境(src-tauri/tauri.prod.conf.json)
{
  "build": { "frontendDist": "../dist", "removeUnusedCommands": true },
  "bundle": { "active": true, "targets": "all" }
}
ベータ環境(src-tauri/tauri.beta.conf.json)
{
  "identifier": "com.company.myapp.beta",
  "productName": "MyApp Beta",
  "plugins": {
    "updater": {
      "endpoints": ["https://beta-releases.example.com/{{target}}/{{arch}}/{{current_version}}"]
    }
  }
}

TOML 設定形式

Tauri.toml を使用する場合、設定にはケバブケースを使用します。

[build]
dev-url = "http://localhost:3000"
before-dev-command = "npm run dev"
before-build-command = "npm run build"

[app]
with-global-tauri = false

[[app.windows]]
title = "My Application"
width = 1200
height = 800
resizable = true
center = true

[app.security]
freeze-prototype = false

[app.security.asset-protocol]
enable = true
scope = ["$APPDATA/**"]

[bundle]
active = true
targets = "all"
icon = ["icons/32x32.png", "icons/128x128.png", "icons/icon.icns", "icons/icon.ico"]

[plugins.updater]
pubkey = "YOUR_PUBLIC_KEY"
endpoints = ["https://releases.example.com/{{target}}/{{arch}}/{{current_version}}"]

一般的な設定パターン

マルチウィンドウアプリケーション
{
  "app": {
    "windows": [
      { "label": "main", "title": "Main Window", "width": 1200, "height": 800, "url": "index.html" },
      { "label": "settings", "title": "Settings", "width": 600, "height": 400, "url": "settings.html", "visible": false }
    ]
  }
}
システムトレイアプリケーション
{
  "app": {
    "trayIcon": { "id": "main-tray", "iconPath": "icons/tray.png", "iconAsTemplate": true },
    "windows": [{ "visible": false }]
  }
}
プラグイン設定
{
  "plugins": {
    "updater": {
      "pubkey": "YOUR_PUBLIC_KEY",
      "endpoints": ["https://releases.example.com/{{target}}/{{arch}}/{{current_version}}"],
      "windows": { "installMode": "passive" }
    },
    "shell": {
      "open": true,
      "scope": [{ "name": "open-url", "cmd": "open", "args": [{ "validator": "\\S+" }] }]
    },
    "deep-link": {
      "mobile": ["myapp"],
      "desktop": { "schemes": ["myapp"] }
    }
  }
}

ロックファイル

再現可能なビルドを実現するため、ロックファイルをコミットしてください。

ファイル用途
Cargo.lockRust の依存関係のバージョンを固定します
package-lock.jsonnpm の依存関係のバージョンを固定します
yarn.lockYarn の依存関係のバージョンを固定します
pnpm-lock.yamlpnpm の依存関係のバージョンを固定します

設定の検証

エディターの自動補完には JSON スキーマを使用してください。

{ "$schema": "https://schema.tauri.app/config/2" }

tauri info を実行して、設定と環境のセットアップを確認してください。

コメント