Combine multiple Lua files into a single compact, executable script
Squish is a powerful build tool that packages multiple Lua scripts, modules, and resources into a single executable file. Perfect for distributing Lua applications and libraries without dependency hassles.
- Module Bundling — Combine multiple Lua modules into one file
- Minification — Strip whitespace, comments, and optimize code
- Uglification — Obfuscate identifiers and compress keywords
- Resource Embedding — Pack any file type into your script
- Debug Support — Preserve line numbers and filenames in tracebacks
- Gzip Compression — DEFLATE algorithm for maximum size reduction
- Bytecode Compilation — Compile to Lua bytecode (experimental)
- Lua 5.2 or later (including Lua 5.3, 5.4, and LuaJIT)
- CMake 3.10+ (for building)
- Make (optional, for Unix-style builds)
# Clone the repository
git clone https://github.com/NathanTBeene/squish.git
cd squish
# Build
cmake -B build
cmake --build build
# Optional: Install system-wide
cmake --install build --prefix /usr/localmake
sudo make install # Optional: Install to /usr/local/bin# Create a squishy file (see below)
lua squish
# Build with minification
lua squish --minify
# Build with uglification
lua squish --uglify
# Build with both
lua squish --minify --uglifyA squishy file defines how to build your project. Create a file named squishy in your project directory.
-- Define output file
Output "myapp.lua"
-- Add modules (will be available via require())
Module "mylib" "src/mylib.lua"
Module "utils" "src/utils.lua"
-- Add main script (executed after modules are loaded)
Main "src/main.lua"
-- Add resources (accessible via require_resource())
Resource "config" "config.json"
-- Set build options
Option "minify"
Option "uglify"Adds a Lua module to the output. Modules are loaded before scripts run.
Module "mymodule" "src/mymodule.lua"Adds a script to execute. Scripts run in order after all modules load.
Main "src/main.lua"Sets the output filename. Default is squished.out.lua.
Output "myapp.lua"Enables an option. Value is optional (defaults to true).
Option "minify"
Option "minify-level" "full"
Option "uglify"Embeds a file as a resource. Access with require_resource("name").
Resource "config" "config.json"
Resource "template" "template.html"Experimental: Auto-fetch missing modules via HTTP.
?is replaced with the module path.
AutoFetchURL "https://raw.githubusercontent.com/user/repo/main/?.lua"Removes whitespace, comments, and optimizes code structure.
Option "minify"
Option "minify-level" "full" -- none, basic, default, full, debug| Level | Description |
|---|---|
none |
No minification |
basic |
Remove comments and excess whitespace |
default |
Basic + optimize whitespace |
full |
Default + optimize locals and strings |
debug |
All optimizations except those that change line numbers |
Compresses keywords and optionally obfuscates identifiers.
Option "uglify"
Option "uglify-level" "full" -- basic, full| Level | Description |
|---|---|
basic |
Compress Lua keywords only |
full |
Compress keywords + frequently used identifiers/strings |
Compresses output using DEFLATE algorithm. Adds ~4KB decompression code.
Option "gzip"Compiles output to Lua bytecode (experimental).
Option "compile"Preserves filenames and line numbers in error messages.
Option "debug"Note: Use
Option "minify-level" "debug"with debug mode to avoid line number mismatches.
Makes embedded resources accessible through standard Lua I/O functions (io.open, dofile, loadfile).
Option "virtual-io"lua squish [directory] [options]
Options:
--minify Enable minification (opt-in)
--minify-level=LEVEL Set minification level
--uglify Enable uglification (opt-in)
--uglify-level=LEVEL Set uglification level
--gzip Enable gzip compression
--compile Compile to bytecode
--debug Enable debug mode
--virtual-io Enable virtual I/O-- squishy
Module "math_utils" "lib/math_utils.lua"
Main "app.lua"
Output "myapp.lua"-- squishy
Module "core" "src/core.lua"
Module "ui" "src/ui.lua"
Main "main.lua"
Output "dist/app.lua"
Option "minify-level" "full"
Option "uglify-level" "full"-- squishy
Module "mylib" "src/mylib.lua"
Resource "schema" "schema.json"
Resource "template" "template.html"
Output "mylib_bundle.lua"
Option "minify"
Option "virtual-io"Automatically generates a squishy file by scanning for require() calls:
lua make_squishy src/*.lua > squishy.newEdit squishy.new as needed, then rename to squishy.
Squish includes pre-configured builds for its own modules:
# Build gzip decompressor
lua squish gzip # Creates gunzip.lua
# Build debug module
lua squish debug # Creates squish.debug- Lua 5.2+ Required — Lua 5.1 is no longer supported
- Opt-in Features — Minify and uglify are now disabled by default
- Add
Option "minify"orOption "uglify"to your squishy file - Or use
--minify/--uglifycommand line flags
- Add
- Update Lua to 5.2 or later
- Add explicit
Option "minify"and/orOption "uglify"to your squishy files - Rebuild your projects
Squish is licensed under the MIT License. See COPYRIGHT for details.
- LuaSrcDiet (minify) — MIT License, Copyright (c) 2008 Kein-Hong Man
- Lua 5.1 — MIT License, Copyright (c) 1994-2008 Lua.org, PUC-Rio
For Maintainers: Automated scripts for building distribution packages
Squish includes build scripts in the release/ folder that automatically create distribution packages from dist.info.
PowerShell (Windows):
cd release
.\build_release.ps1 # Build all variants
.\build_release.ps1 -Clean # Clean and rebuildBash (Linux/macOS):
cd release
./build_release.sh # Build all variants
./build_release.sh --clean # Clean and rebuildThe scripts automatically read version information from dist.info and create:
Lua Scripts:
squish-basic-vX.X.X.lua— Basic squish without featuressquish-full-vX.X.X.lua— All features includedsquish-minify-vX.X.X.lua— Minify support onlysquish-uglify-vX.X.X.lua— Uglify support onlygunzip-vX.X.X.lua— Standalone gzip decompressorsquish-debug-vX.X.X.lua— Debug support module
Archives:
squish-lua-vX.X.X.zip/tar.gz— All Lua scriptssquish-complete-vX.X.X.zip/tar.gz— Scripts + documentationSHA256SUMS.txt— Checksums for verification
All files are created in release/dist/ and are ready for GitHub release.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes following the guidelines
- Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CHANGES for version history.
- Original Author: Matthew Wild
- Maintainers: Peter Drahoš, aten.dev
- Lua 5.2+ Port: aten.dev (2026)
Made with ❤️ for the Lua community