Site Code

Frontend Builds

Information is for advanced users who have a desire to have a completely custom build for their Dijon Platform site.

Static versioning

Dijon Platform requires that your Javascript build generates a file called lib/assets_version.php. This is used by Dijon Platform to force new versions of Javascript and CSS assets to be downloaded by browsers when these changes.

Both our Bootstrap and Tailwind example sites ship with this already setup.

lib/assets_version.php
<?php

function getAssetVersion() : string
{
    return 'some_string_that_indicates_a_version';
}

Javascript and CSS

Your frontend build with a tool such as Webpack or Yarn should result in at the following files:

  • www_frontend/js_dist/app.js
  • www_frontend/js_dist/edit.js
  • www_frontend/css/app.css
  • www_frontend/css/edit.css

Dijon Platform uses app.js as its entry point when displaying a site and edit.js as the entry point when it displays sites in the WYSIWYG editor. The same applies to app.css and edit.css.

.node_version

Create a file called .node_version in the root of your site and put the the version of Node you want to use to build your site. The Dijon Platform automated build system will check to see if this file exists and use that version of Node to build your site static assets when deploying your site.

build.sh

Create a bash script that runs the command you need to run when building your site. This script should install all the required dependencies and then run whatever is necessary to perform a production build of your site.

Make sure your build.sh script is marked as executable with chmod +x.

The Webpack example is from our Tailwindcss demo site.

Webpack Example
#!/bin/bash

set -ex

mkdir -p www_frontend/css www_frontend/js_dist
npm i
npm run build:prod

The Yarn example is from our Bootstrap demo site.

Yarn Example
#!/bin/bash

set -ex

rm -rf www_frontend/js_dist/* 
rm lib/assets_version.php
yarn install --check-files
npm rebuild node-sass
yarn run prod:build

On this page