JavaScript processing and source maps
The packer can minify or obfuscate JavaScript before compression and encryption. It processes each file separately and preserves the resource layout. Compile TypeScript, JSX and frontend sources with your build tools first. For bundling npm dependencies, see Imports and npm dependencies.
Configure processing
Section titled “Configure processing”Add this section to the publishing configuration from Package and publish client resources:
[resources.pack.scripts]mode = "minify"paths = ["scripts"]source_maps = trueFor development with automatic server packaging, the same section goes in the
server’s config.toml. A production server using mode = "remote" loads the
published result. Its configuration has no [resources.pack] section.
When omitted, paths defaults to ["scripts"] and source_maps to false.
| Mode | Behavior |
|---|---|
"off" |
Default. Leaves script contents unchanged. |
"minify" |
Compacts code and shortens local identifiers. |
"obfuscate" |
Uses less readable identifiers and moves some strings into lookup arrays. |
Imports, exported names and property names are preserved. Processing keeps each module in its own file. HTML, CSS and other non-JavaScript content retain their original bytes before compression and encryption.
Obfuscation can increase file size and runtime work. Check the packaged scripts in the game before publishing that mode to players. See Resource encryption and keys for encryption settings and the handling of client-readable content.
Select files
Section titled “Select files”paths contains files or folders relative to resources.pack.path. With
resources.pack.path = "client", selecting "scripts" processes JavaScript
under client/scripts/, including its subfolders.
To include a WebView’s built scripts as well:
[resources.pack.scripts]mode = "minify"paths = ["scripts", "ui/assets"]source_maps = trueUse forward slashes and match the spelling and case of the resource paths.
Wildcards such as "scripts/*.js" are rejected. A file can be selected directly,
for example "scripts/client.js".
With minify or obfuscate enabled, selected files are handled as follows:
| File | Behavior |
|---|---|
.js, .mjs |
Processed before packaging. |
.map, .d.ts |
Excluded from the package. |
.ts, .tsx, .jsx |
Packing fails. Build them into JavaScript first. |
Other extensions, including .cjs |
Packaged without script processing. |
Files outside the selected paths are still packaged. The exclusions above apply
only to selected paths while processing is enabled. With mode = "off", maps
and declarations are also included if they remain in the source folder.
If your frontend build already produces the required minified output, leave
its folder outside paths to keep those bytes unchanged.
Keep source maps
Section titled “Keep source maps”source_maps = true saves debugging maps for processed files under:
<resources.path>/cache/scripts/Each generated .map has a matching .json record containing the resource path
and processed code. The maps include the JavaScript supplied to the packer.
Keep this directory private. It is excluded from resource-tool publish and
from the built-in resource HTTP server.
Keep the maps and processed code with the corresponding release’s manifest
hash. The cache can contain records from earlier builds. For a separate output
per release, use --output with the publication command:
& "C:\Revo\resource-tool\resource-tool.exe" publish --config .\publish.toml --output .\dist\release-001Use a new output folder for the next release and retain its private cache with
your deployment files. The same resources.key can be used for every release.
Maps describe the transformation from the JavaScript given to the packer to the packaged code. Maps from an earlier TypeScript or bundler build remain separate. Retain those with your build output if you need to trace errors back to the original source files.
Client logs report positions in the processed scripts. Use the matching map
from that release to resolve the original location. Private maps are kept on
the publishing machine, so enabling source_maps does not automatically change
client stack traces or load maps into DevTools.
For interactive debugging, use a development package with mode = "off".
WebView debugging is covered in Debug WebViews.
Rebuild and publish
Section titled “Rebuild and publish”Changing the processing mode, selected paths or map setting takes effect on the next pack or publish. Existing source files stay unchanged. Unchanged processing results are reused from the private cache when their inputs and settings match.
Script processing settings can change while reusing the existing package output folder. Keep the server restart and client reconnect steps from the publishing guide.
If processing fails, the command reports the resource path and exits with an error before selecting a new release. Fix the source or configuration and run the command again.
| Message | Action |
|---|---|
Compile TypeScript/JSX to JavaScript before packing |
Point the packer at built files and remove source-only files from the selected folder. |
Could not transform <path> |
Check the reported parser or transformation error. To inspect the original script in a development build, set the mode to off. |
resources.pack.scripts.mode must be off, minify or obfuscate |
Use one of the listed mode strings. |