Export Scripts

Export scripts are executable scripts or programs, that the app runs every time you export your design. You can use them to rename files, move images, run things like eslint or even upload your site automatically to your server.

To do any of this, though, you need to be comfortable with writing code. This is why the feature is hidden in the Advanced area in Export Settings:

You point it to an executable file (can be a bash script, an exe program or anything else that can be run from a terminal). For Mac and Linux, making a file executable involves setting the +x flag. For Windows, regular batch files or compiled programs would work.

The export destination path is passed as arg 1, so you can cd $1 to navigate to the folder in your script.

Here is an example, written in bash, which changes the extension of your index file to php:

#!/bin/bash
cd $1
mv index.html index.php

For more complex tasks, you can write your scripts in Node, Python, Ruby, PHP or anything else that you feel comfortable with. Just make sure that the script is marked as executable, and that the #! row is added, so that the interpreter can be located by the os.

If your script throws any errors, they will be written to an error.log file in the export folder.

Tip: For Windows users, one option for writing your scripts is to use Python and py2exe.