Using Squiffy from the command line
Installing
Section titled “Installing”As an alternative to the web editor, Squiffy is also available as a command-line Node package. This runs on Windows, Mac and Linux.
To install the Squiffy compiler, first install Node.js.
You can then run the CLI directly using npx:
npx @textadventures/squiffy-cli mygame.squiffyAlternatively, install it globally:
npm install @textadventures/squiffy-cli -gIf the install fails: On a Mac or Linux, if you get an error installing, try using sudo:
sudo npm install @textadventures/squiffy-cli -gYou can create a Squiffy file in any text editor - Notepad, VS Code, Sublime Text, TextEdit etc.
Squiffy files are text files with a .squiffy file extension.
To transform a Squiffy file into a working browser-based game, go to its directory in a command prompt and type:
npx @textadventures/squiffy-cli mygame.squiffySquiffy will write four files to the same folder as the script file:
index.html- the main HTML pagestyle.css- the stylesheetstory.js- your compiled storysquiffy.runtime.global.js- the Squiffy runtime
Launch index.html to play the game.
This folder of files can now be uploaded anywhere, and it will run entirely locally in the player’s web browser (the source .squiffy script file does not need to be included).
The browser’s local storage will be used to save the state of the game. This means the player can close their browser, and the next time they go back to that page, the game will resume from where they left off.
Note: Even if you recompile a game, the previous state will still be loaded. This means that after making a change to your game, you’ll need to click the Restart link at the top of the screen to see your changes.
Output Formats
Section titled “Output Formats”Squiffy supports different output formats depending on how you want to distribute your game.
Standard (multiple files)
Section titled “Standard (multiple files)”The default output creates four separate files as described above. This is ideal for:
- Hosting on a web server
- Situations where you want to customize the HTML or CSS
- Development and debugging (easier to inspect individual files)
Single HTML file (inline)
Section titled “Single HTML file (inline)”Use --inline to create a single self-contained HTML file with all CSS, JavaScript, and story content embedded:
npx @textadventures/squiffy-cli mygame.squiffy --inlineThis creates just one file: index.html. This is ideal for:
- Easy sharing (just send one file)
- Uploading to platforms that only accept a single HTML file
- Offline distribution
- Embedding in other documents
Zip file
Section titled “Zip file”Use --zip to create a zip archive of the output files:
npx @textadventures/squiffy-cli mygame.squiffy --zipYou can combine this with --inline to create a zip containing just the single HTML file:
npx @textadventures/squiffy-cli mygame.squiffy --inline --zipOptions
Section titled “Options”HTTP Server
Section titled “HTTP Server”Use --serve (or -s) to start a local HTTP server after compiling. This opens your game in a browser for testing:
npx @textadventures/squiffy-cli mygame.squiffy --serveOptionally specify a port using --port (or -p):
npx @textadventures/squiffy-cli mygame.squiffy --serve --port 3000The default port is 8282.
Script only
Section titled “Script only”Use --scriptonly to generate only the story.js file, without overwriting the other files. This is useful when you’ve customized index.html or style.css and only want to update the story:
npx @textadventures/squiffy-cli mygame.squiffy --scriptonlyYou can optionally specify a custom filename:
npx @textadventures/squiffy-cli mygame.squiffy --scriptonly myscript.js