Appearance
metaplay deploy webclient [ENVIRONMENT] [NAME] [flags]
[preview] Deploy a web game client to the environment's CDN
Appearance
[preview] Deploy a web game client to the environment's CDN
metaplay deploy webclient [ENVIRONMENT] [NAME] [flags] PREVIEW: This command is in preview and subject to change!
Upload a web client to the target environment's CDN. The environment decides where the web client goes: today that is the root of the environment's public CDN, https://<environment>-assets.<domain>/, and an environment that hosts web clients elsewhere says where in its details. The command prints the URL. It uploads the files in the web client's sourceDir as they are, so build the web client first.
Configure web clients in the 'webClients' section of metaplay-project.yaml. For example, with the Metaplay SDK's preset for Blazor WebAssembly clients:
webClients: - name: webclient sourceDir: WebClient/bin/Release/net10.0-browser/publish/wwwroot preset: blazor
Fields of a web client:
name: identifies the web client in this command.
sourceDir: directory of the built files, relative to metaplay-project.yaml.
preset: the name of one of the Metaplay SDK's presets to start from: 'blazor' for Blazor WebAssembly clients. A preset is a YAML file of the fields below except prefix, and the SDK has its presets in <sdkRootDir>/WebClientPresets/.
presetFile: a preset file of the project's own to start from, instead of an SDK preset, relative to metaplay-project.yaml.
prefix: path under the environment's web client location to upload to, eg, 'staging/'. Usually left out.
files: rules for how the files in sourceDir become objects in the bucket. A file follows the first rule that matches its path, and is uploaded under its own name if none does. A rule can remove a suffix from the name (stripSuffix), set the Content-Encoding of the file's bytes (contentEncoding), or leave the file out (exclude). Where two files would become the same object, as app.css.br and app.css do below, the file the earlier rule matched is uploaded, and a file no rule matched loses to one that a rule did:
files: - match: "/*.br" stripSuffix: .br contentEncoding: br - match: "/*.gz" exclude: true
objects: rules that set the Content-Type (contentType), Cache-Control (cacheControl) and upload order (uploadOrder) of the objects whose name they match. For each of these, the first matching rule that sets it wins:
objects: - match: "art/**" cacheControl: public, max-age=86400 - match: index.html uploadOrder: 1
Without a rule, Content-Type comes from the object's name, Cache-Control is 'no-cache' and uploadOrder is 0. Objects are uploaded in ascending uploadOrder, each order's uploads finished before the next starts, so a file that names others, such as index.html, can go up after them. A page loaded during a deploy then finds the objects it names.
endpointsFile: name of a JSON file to write next to the web client, for the client to read at startup. It holds the file's format and the game server's and the CDN's addresses, as far as the environment reports them: format, serverHost, serverPortForWebSocket, enableTls, cdnBaseUrl and publicWebApiUrl. A field the environment does not report is left out, and no file is written where it reports no game server or CDN. The SDK's 'blazor' preset sets it to 'metaplay-endpoints.json', the name the SDK's client reads.
A rule matches by a glob (match) or a regular expression (matchRegex). A web client's settings override its preset's: its files and objects rules are checked before the preset's, and its endpointsFile replaces the preset's. Use --dry-run to see the resulting configuration, and the headers and upload order of each object.
A deploy uploads only the files that changed since the last deploy, and never deletes files from the bucket. It records the files it uploaded in '<prefix>.metaplay-site.json', and before skipping a file, checks that the bucket still holds it as recorded. A file that an interrupted deploy, or a change made outside a deploy, left different is uploaded again.
The bucket also holds the game server's files, so the command refuses to upload under the names the game server uses, such as GameConfig/ and Volatile/.
Expected arguments:
Related commands:
# Deploy the project's web client to environment nimbly.
metaplay deploy webclient nimbly
# Show the configuration and the headers of each file, without uploading anything.
metaplay deploy webclient nimbly --dry-run
# Deploy the web client named 'webclient', when the project has several.
metaplay deploy webclient nimbly webclient--concurrency <int>: Number of files to upload at once (default: 16)--dry-run: Show what would be uploaded without uploading anything--reset-manifest: Ignore the last deploy's manifest: upload all files and start a new one--color <string>: Should the output be colored (yes/no/auto)? [env: METAPLAYCLI_COLOR] (default: auto)--project <string>: Path to the to project directory (where metaplay-project.yaml is located)--skip-version-check: Skip the check for a new CLI version being available--verbose: Enable verbose logging, useful for troubleshooting [env: METAPLAYCLI_VERBOSE]