-
Notifications
You must be signed in to change notification settings - Fork 0
Build profiles
It is common to be simultaneously working with different versions of a website, each of which needs to be built in slightly different ways. A common scenario is to have a local version of the site so that you can test it on your own machine, and a production version that is deployed to a server. In Salal, build profiles are used to store information about how to build and deploy the site in each case.
Build profile configuration files must be placed in a directory config/profiles. They have the same format as any other Salal config file. The name of the profile is taken from the name of the config file. For example, if you have a file config/profiles/production.json, you can use that profile by specifying production after the action when you run Salal, like python -m salal build production.
If you specify a profile when you run Salal, the corresponding configuration file will be loaded after the project configuration. This means that if a variable in the profile configuration has the same name as one in the project configuration, the value specified for the profile will override the one specified for the project.
To illustrate how you might use build profiles, suppose you have a Python backend for your site. As part of that, you have several Python scripts that are run to handle requests coming in from the client. These scripts need to indicate where the Python interpreter can be found. And it's in a different location on the test machine and on the server. That can be handled with a global variable. First, put a variable reference in your script files:
#!{{globals.python_path}}
Then, specify the appropriate path for each profile in the profile config file. For example, you might do this for a local profile:
{
"globals": {
"python_path": "C:/msys64/mingw64/bin/python.exe"
}
}
And then do this for a production profile:
{
"globals": {
"python_path": "/home/sally/opt/python-3.6.2/bin/python3"
}
}
This technique can also be used for building web pages, CSS, JavaScript scripts, or any other kind of file where you've configured Salal to do variable substitution.
- Home
- About Salal
- Installation
- Tutorials
- Core concepts
- Getting more out of Salal
- Advanced topics
- Change log