Skip to content

Using Squiffy from the command line

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.squiffy

Alternatively, install it globally:

npm install @textadventures/squiffy-cli -g

If the install fails: On a Mac or Linux, if you get an error installing, try using sudo:

sudo npm install @textadventures/squiffy-cli -g

You 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.squiffy

Squiffy will write four files to the same folder as the script file:

  • index.html - the main HTML page
  • style.css - the stylesheet
  • story.js - your compiled story
  • squiffy.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.

Squiffy supports different output formats depending on how you want to distribute your game.

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)

Use --inline to create a single self-contained HTML file with all CSS, JavaScript, and story content embedded:

npx @textadventures/squiffy-cli mygame.squiffy --inline

This 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

Use --zip to create a zip archive of the output files:

npx @textadventures/squiffy-cli mygame.squiffy --zip

You can combine this with --inline to create a zip containing just the single HTML file:

npx @textadventures/squiffy-cli mygame.squiffy --inline --zip

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 --serve

Optionally specify a port using --port (or -p):

npx @textadventures/squiffy-cli mygame.squiffy --serve --port 3000

The default port is 8282.

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 --scriptonly

You can optionally specify a custom filename:

npx @textadventures/squiffy-cli mygame.squiffy --scriptonly myscript.js