Skip to content

MangkorN/serve-unity-mod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serve-unity-mod

A lightweight Node.js server for serving Unity WebGL builds with precompressed assets (Brotli / Gzip), designed for fast local development and minimal runtime overhead.

This is a modified fork of serve-unity, tailored for modern Unity WebGL builds that already output .br files.


Features

  • Serves precompressed Unity WebGL builds (.br, .gz) without runtime recompression.
  • Correctly sets Content-Encoding and Content-Type headers for Unity assets:
    • .wasm.brapplication/wasm
    • .js.brapplication/javascript
    • .data.brapplication/octet-stream
  • Serves the current working directory, making it easy to run from anywhere.
  • Optional fallback to precompressed variants when available (e.g. serve foo.wasm.br for a foo.wasm request if the client supports Brotli).
  • Zero external dependencies beyond Node.js.
  • Designed for local development and simple static hosting workflows.

What’s Different from serve-unity

  • Removed dynamic on-the-fly Brotli/Gzip compression (avoids unnecessary CPU usage).
  • Optimized for Unity WebGL builds that already generate precompressed assets.
  • Removed promotional messages and external upload links.
  • Renamed CLI to avoid clashing with the upstream package.

Installation

Choose one of the following installation methods:

Option A: Install directly from Git (recommended for personal use)

Install the CLI globally from the GitHub repository:

npm install -g git+https://github.com/MangkorN/serve-unity-mod.git

This installs serve-unity-mod into your system without needing to clone the repository locally. To update, re-run the install command. If npm keeps the older commit, run npm uninstall -g serve-unity-mod first, then install again.

Option B: Local development (recommended if modifying the code)

Clone or unzip this repository, then run:

npm install
npm link

This creates a global command that points to your local working copy. Changes take effect immediately (linked to your working copy).

Option C: Global install snapshot (local repo)

Clone or unzip this repository, then run:

npm install
npm install -g .

This installs a snapshot of the local repository globally. Re-run npm install -g . to pick up changes.


Usage

Run the server in the directory containing your Unity WebGL build:

serve-unity-mod <port>

Example:

cd Build/
serve-unity-mod 9000

Then open:

http://localhost:9000

Default Behavior

  • If no port is specified, the server defaults to 9000.
  • The server always serves the current working directory.
  • Precompressed files (.br, .gz) are served as-is with correct headers.

Typical Unity Build Output Supported

mygame.data.br
mygame.framework.js.br
mygame.wasm.br
mygame.loader.js

This is the standard output for Unity WebGL builds using Brotli compression.


License

MIT License.

This project is a modified derivative of the original serve-unity project. Original copyright and license notices are preserved.


Author

  • Original project by Rocco Balsamo
  • Modifications by Mangkorn Yuan

About

A modded version of https://github.com/TheRoccoB/serve-unity for my personal needs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors