silverstripe-manifestassets
Get the path of an asset from a generated assets manifest file., (*1)
Usage
In your template you can get the url to your asset:, (*2)
<script src="$ManifestAsset('awesome.js')" type="application/javascript"></script>
It also works with Requirements:, (*3)
<% require js($ManifestAsset('awesome.js')) %>
To get the url to your asset in PHP:, (*4)
$pathToAwesomeJs = ManifestAssets::getPath('awesome.js');
Configuration
In your site config, you'll must configure a base path to your assets manifest file:, (*5)
ManifestAssets:
base_path: themes/awesome/dist/js
By default it looks for a manifest.json
file, but if you have a different name:, (*6)
ManifestAssets:
base_path: themes/awesome/dist/js
file_name: assets.json
Requirements
Installation
The recommended way to install is through Composer:, (*7)
composer require jacobbuck/silverstripe-manifestassets