Packaging

PAX bundles JavaScript, CSS, optional Sass, and npm packages into public/app.js and public/app.css. No Node.js is required on the server.

Overview


front/lib/package.json

The manifest for npm dependencies and build order.

{
    "dependencies": {
        "pax-js-framework": "0.0.158"
    },
    "build": {
        "scss": ["*"],
        "css": ["*"],
        "js": ["*"]
    }
}
KeyDescription
dependenciesnpm packages downloaded to front/lib/
build.jsJS files from front/js/ — use "*" for all files
build.cssCSS from front/css/
build.scssSass compiled to front/cache/css/ before concat

Build patterns: "*", "app.js", or "utils/*.js". Files are concatenated in alphabetical order.


Build modes

SettingBehavior
SITE_BUILD=1Auto-rebuild when source files change (development)
SITE_BUILD=0No builds — serve committed public/ files (production)
/dev/buildForce rebuild when SITE_BUILD=1, then redirect home
// template.php (default build hook)
$pkg = $app->get('package');
if(SITE_BUILD && $pkg->needsBuild()) $pkg->build();

Setup

cp .env.example .env
composer install

Set SITE_BUILD=1 in .env for local development. Sass requires scssphp/scssphp from Composer.


Header & footer

Templates link bundled assets with cache busting:

<link rel="stylesheet" href="/public/app.css?v=<?=filemtime(FILE_CSS)?>">
<script src="/public/app.js?v=<?=filemtime(FILE_JS)?>"></script>

Production