-
-
Notifications
You must be signed in to change notification settings - Fork 0
Different environments
One project often needs slightly different build steps in different places. A local development build may generate source maps, while a production build may omit them. Build handles this through modes.
The mode name is inserted before the file extension:
-
build.ini+ modeproductionbecomesbuild.production.ini -
build.json+ modeproductionbecomesbuild.production.json
To use a mode:
vendor/bin/build --mode production
vendor/bin/build -m devBuild loads the base configuration first, then loads the mode file, then recursively merges the two.
Base configuration:
build.ini
[script/**/*.es6]
name=Bundle JavaScript
require=node_modules/.bin/esbuild >=0.17
execute=./node_modules/.bin/esbuild ./script/app.es6 --bundle --sourcemap --outfile=./www/script.js
[style/**/*.scss]
name=Compile Sass
require=sass >=1.6
execute=sass ./style/style.scss ./www/style.cssProduction override:
build.production.ini
[script/**/*.es6]
name=Bundle JavaScript for production
execute=./node_modules/.bin/esbuild ./script/app.es6 --bundle --minify --outfile=./www/script.jsThe production file only contains the task that changes.
Running vendor/bin/build --mode production keeps the Sass task from build.ini, but replaces the name and execute values of the JavaScript task with those from build.production.ini.
Mode files do not need to repeat the whole task definition.
For example, if we only want to change the arguments in an execute command, we can override just that property and leave the requirements and block name alone.
A mode file can also introduce brand new tasks.
For example, a build.dev.ini file might add a sitemap generator or some diagnostic step that only runs during development.
If we ask for a mode and the corresponding file does not exist, Build stops with an error rather than silently continuing with the wrong configuration.
That makes deployment mistakes more obvious when they happen.
Next, read default config to see how shared defaults and project-specific overrides fit together.
PHP.GT/Build is a separately maintained component of PHP.GT/WebEngine.