Skip to content
Greg Bowler edited this page Oct 19, 2023 · 9 revisions

This project provides a system for defining and running client-side build processes automatically, using tools already installed by your favourite client-side dependency manager.

This library assumes the environment of the system is already configured.

The primary objective is to provide a client-side build system that is automatically configured for PHP projects, leaving the configuration of the system down to the developer's choice of client-side dependency management software.

Quick example

Your project's build requirements are defined in the build.json file, and describe what command to run when source files change within a certain file-matching pattern.

Notice how files can trigger either running a PHP dependency within vendor/bin, running a local client-side dependency within node_modules, or running a system-installed program.

build.json:

{
	"script/**/*.es6": {
		"require": {
			"node": "*",
			"./node_modules/.bin/esbuild": ">=0.17.12"
		},
		"execute": {
			"command": "./node_modules/.bin/esbuild",
			"arguments": ["script/script.es6", "--bundle", "--sourcemap", "--outfile=www/script.js", "--loader:.es6=js", "--target=chrome105,firefox105,edge105,safari15"]
		}
	},

	"script/**/*.js": {
		"require": {
			"vendor/bin/sync": "*"
		},
		"execute": {
			"command": "vendor/bin/sync",
			"arguments": ["--pattern", "*.js", "script", "www/script"]
		}
	},

	"style/**/*.scss": {
		"require": {
			"sass": ">=1.6"
		},
		"execute": {
			"command": "/usr/local/bin/sass",
			"arguments": ["./style/style.scss", "www/style.css"]
		}
	},

	"style/**/*.css": {
		"require": {
			"vendor/bin/sync": "*"
		},
		"execute": {
			"command": "vendor/bin/sync",
			"arguments": ["--pattern", "*.css", "style", "www/style"]
		}
	},

	"asset/**/*": {
		"require": {
			"vendor/bin/sync": ">=1.3.0"
		},
		"execute": {
			"command": "vendor/bin/sync",
			"arguments": ["./asset", "./www/asset", "--symlink"]
		}
	}

	"data/upload/**/*": {
		"require": {
			"vendor/bin/sync": "*"
		},
		"execute": {
			"command": "vendor/bin/sync",
			"arguments": ["data/upload", "www/data/upload", "--symlink"]
		}
	}
}

Learn about command line usage in the next section.