--- sidebar_position: 5 --- # 项目配置 项目配置在项目目录中的`wails.json`文件中。 配置的结构是: ```json { "name": "[项目名称]", "assetdir": "[资源目录的相对路径]", "reloaddirs": "[触发重新加载的附加目录(逗号分隔),这仅用于一些重要资源配置]", "frontend:install": "[安装 node 依赖的命令,在 frontend 目录下运行 - 通常是 `npm install`]", "frontend:build": "[构建资源的命令,在 frontend 目录下运行 - 通常是 `npm run build`]", "frontend:dev": "[此命令已被 frontend:dev:build 替代。 If frontend:dev:build is not specified will falls back to this command. If frontend:dev:build is not specified will falls back to this command. 如果没有指定 frontend:dev:build 将回退到该命令,如果此命令也没有指定将回退到 frontend:build]", "frontend:dev:build": "[此命令等效于开发模式中的 frontend:build,如果没有指定则回退到 frontend:dev]", "frontend:dev:install": "[此命令等效于开发模式中的 frontend:install,如果没有指定则只有 frontend:install]", "frontend:dev:watcher": "[此命令在 `wails dev` 上的单独进程中运行。 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. 对第 3 方观察者有用]", "frontend:dev:serverUrl": "[使用第三方开发服务器提供资源,比如 Vite", "wailsjsdir": "[自动生成的JS模块将被创建的目录的相对路径]", "version": "[项目配置版本]", "outputfilename": "[二进制文件的名称]", "debounceMS": 100, // 在检测到资源更改时,开发服务器等待重新加载的时间 "devServer": "[将 wails 开发服务器绑定到的地址。 默认:localhost:34115]", "appargs": "[在dev模式下以shell样式传递给应用程序的参数]", "runNonNativeBuildHooks": false, // 定义构建钩子是否应该运行,尽管它们是为主机操作系统以外的操作系统定义的。 "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": "[在构建指定的 GOOS/GOARCH 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 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/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": "[在构建指定的 GOOS/GOARCH 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 ]", "GOOS/*": "[在构建指定的 GOOS 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 'GOOS/GOARCH'钩子在'GOOS/*'和'*/*'钩子之前执行。 ]", "GOOS/*": "[在构建指定的 GOOS 后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 'GOOS/*'钩子在'*/*'钩子之前执行。 ]", "*/*": "[每次构建后将执行的命令:${platform} 替换为'GOOS/GOARCH',${bin} 替换为编译后的二进制文件的路径。 ]" }, "info": { // 用于填充 manifests 和 version 信息的数据。 "companyName": "[公司名称。 默认: [项目名]]", "productName": "[产品名称。 默认: [项目名]]", "productVersion": "[产品的版本。 默认: '1.0.0']", "copyright": "[产品的版权。 默认: 'Copyright.........']", "comments": "[该应用程序的简短注释。 默认: 'Built using Wails (https://wails.app)']" }, "nsisType": "['multiple': 每个架构一个安装程序。 'single': 适用于所有正在构建的架构的单一通用安装程序。 默认: 'multiple']" } ``` 该文件将在运行`wails build`或`wails dev`时,由 Wails CLI 读取。 `wails build/dev`命令中的`assetdir`、`reloaddirs`、`wailsjsdir`、`debounceMS`、`devserver`和`frontenddevserverurl`标志将覆盖项目配置并作为后续运行的默认值。