Asset Bundle

The Asset Bundle provides implementation of a version strategy that accepts a JSON manifest file.

Usage

For basic use cases, only requiring this bundle in your composer.json is necessary. It already declares symfony/asset as a dependency.

The bundle automatically registers its version strategy in Symfony’s Asset Bundle configuration. Make sure you don’t set the framework.assets.version_strategy configuration option, because it would override configuration set by this bundle.

Optionally, you can customize the manifest file location, see the Configuration section below.

Configuration

You can configure the manifest file path using the manifest_path key as follows:

config/packages/enginiro_asset.yml
enginiro_asset:
    manifest_path: '%kernel.project_dir%/var/dat/asset-hashes.json'

The default value is shown in the snippet above.

Manifest file format

The manifest file must be a JSON object. Keys are asset paths and values their hash. Paths must not be prefixed with a slash.

Example
{
	"assets/css/stylesheet.css": "abcd12345",
	"assets/js/script.js": "defg67890"
}

You can use gulp-buster to generate the manifest. For example:

const gulpBuster = require('gulp-buster');

function buster() {
	return gulp.src('public/assets/**/*')
	           .pipe(gulpBuster({
	           	fileName: 'asset-hashes.json',
	           	relativePath: 'public'
	           }))
	           .pipe(gulp.dest('var/dat'));
});

exports.buster = buster;