Scripts

## Pre/Post Build/Serve Scripts

Nift has support for you to optionally add in pre/post build/serve scripts to your websites. Just a few of the things this can be useful for includes integrating with webpack, Babel, SASS, Grunt, Python webserver, Live Server, Live Reload, etc.. You can use any scripting or programming language you want, eg. batch, bash shell, C/C++, C#, fish, go, Haskell, Java, Javascript, Objective-C, Perl, PHP, Python, Ruby, Swift, Zsh shell and many more.

Note: Make sure your scripts have executable permissions, otherwise Nift will be unable to run them and should throw a build error.

Website-wide scripts should reside in the project root directory in a file to be named as follows:

pre-build.scripts
post-build.scripts
pre-build-all.scripts
post-build-all.scripts
pre-build-updated.scripts
post-build-updated.scripts
pre-serve.scripts
post-serve.scripts

It should be reasonably self-explanatory what each will do, though note the pre-build and post-build scripts are run before or after each of the Nift commands build, build-all, build-updated. Each line should have a single script, though you can leave lines blank and any line starting with # will be treated as a comment.

An example pre-build.scripts file is below:

#scripts to run before building pages
./"test script.py"

./"test.py"
./test.py

python "test this.py"
python 'test this.py'

curl -sS "https://pastebin.com/raw/1kYKafED"

Note: You should prepend ./ before scripts and programs so that your websites will build cross-platform (provided you use cross-platform scripting/programming languages, tools etc.).

Page specific scripts should reside in the same directory as the content file for the page in a file to be named as follows:

pagename.pre-build.scripts
pagename.post-build.scripts

Note: Scripts are run from the project root directory.

Each line should have a single script, though you can leave lines blank and any line starting with # will be treated as a comment.