---
sidebar_position: 5
---

# 项目配置

项目配置在项目目录中的 `wails.json` 文件中。 配置的结构是：

```json
{
    "name": "[The project name]",
    "assetdir": "[Relative path to the directory containing the compiled assets, this is normally inferred and could be left empty]",
    "reloaddirs": "[Additional directories to trigger reloads (comma separated), this is only used for some advanced asset configurations]",
    "build:dir": "[The directory where the build files reside. Defaults to 'build']",
    "frontend:dir": "[Relative path to the frontend directory. Defaults to 'frontend']",
    "frontend:install": "[The command to install node dependencies, run in the frontend directory - often `npm install`]",
    "frontend:build": "[The command to build the assets, run in the frontend directory - often `npm run build`]",
    "frontend:dev": "[This command has been replaced by frontend:dev:build. If frontend:dev:build is not specified will falls back to this command. \nIf this command is also not specified will falls back to frontend:build]",
    "frontend:dev:build": "[This command is the dev equivalent of frontend:build. If not specified falls back to frontend:dev]",
    "frontend:dev:install": "[This command is the dev equivalent of frontend:install. If not specified falls back to frontend:install]",
    "frontend:dev:watcher": "[This command is run in a separate process on `wails dev`. Useful for 3rd party watchers or starting 3d party dev servers]",
    "frontend:dev:serverUrl": "[URL to a 3rd party dev server to be used to serve assets, EG Vite. \nIf this is set to 'auto' then the devServerUrl will be inferred from the Vite output]",
    "wailsjsdir": "[Relative path to the directory that the auto-generated JS modules will be created]",
    "version": "[Project config version]",
    "outputfilename": "[The name of the binary]",
    "debounceMS": 100, // The default time the dev server waits to reload when it detects a change in assets
    "devServer": "[Address to bind the wails dev sever to. Default: localhost:34115]",
    "appargs": "[Arguments passed to the application in shell style when in dev mode]",
    "runNonNativeBuildHooks": false, // Defines if build hooks should be run though they are defined for an OS other than the host OS.
    "preBuildHooks": {
        "GOOS/GOARCH": "[The command that will be executed before a build of the specified GOOS/GOARCH: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]",
        "GOOS/*": "[The command that will be executed before a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH". The "GOOS/*" hook is executed before the "*/*" hook.]",
        "*/*": "[The command that will be executed before every build: ${platform} is replaced with the "GOOS/GOARCH".]"
    },
    "postBuildHooks": {
        "GOOS/GOARCH": "[The command that will be executed after a build of the specified GOOS/GOARCH: ${platform} is replaced with the "GOOS/GOARCH" and ${bin} with the path to the compiled binary. The "GOOS/GOARCH" hook is executed before the "GOOS/*" and "*/*" hook.]",
        "GOOS/*": "[The command that will be executed after a build of the specified GOOS: ${platform} is replaced with the "GOOS/GOARCH" and ${bin} with the path to the compiled binary. The "GOOS/*" hook is executed before the "*/*" hook.]",
        "*/*": "[The command that will be executed after every build: ${platform} is replaced with the "GOOS/GOARCH" and ${bin} with the path to the compiled binary.]"
    },
    "info": { // Data used to populate manifests and version info.
        "companyName": "[The company name. Default: [The project name]]",
        "productName": "[The product name. Default: [The project name]]",
        "productVersion": "[The version of the product. Default: '1.0.0']",
        "copyright": "[The copyright of the product. Default: 'Copyright.........']",
        "comments": "[A short comment of the app. Default: 'Built using Wails (https://wails.app)']"
    },
    "nsisType": "['multiple': One installer per architecture. 'single': Single universal installer for all architectures being built. Default: 'multiple']",
    "obfuscated": "[Whether the app should be obfuscated. Default: false]",
    "garbleargs": "[The arguments to pass to the garble command when using the obfuscated flag]"
}
```

该文件将在运行 `wails build` 或 `wails dev` 时，由 Wails CLI 读取。

`wails build/dev` 命令中的 `assetdir`、`reloaddirs`、`wailsjsdir`、`debounceMS`、`devserver` 和 `frontenddevserverurl` 标志将覆盖项目配置并作为后续运行的默认值。

此文件的 JSON 模型位于 [此处](https://wails.io/schemas/config.v2.json)。
