jacobbuck / silverstripe-manifestassets
Get the path of an asset from a generated assets manifest file.
Installs: 6 102
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Type:silverstripe-module
Requires
- silverstripe/framework: ~3.1
This package is not auto-updated.
Last update: 2022-08-06 17:03:33 UTC
README
Get the path of an asset from a generated assets manifest file.
Usage
In your template you can get the url to your asset:
<script src="$ManifestAsset('awesome.js')" type="application/javascript"></script>
It also works with Requirements:
<% require js($ManifestAsset('awesome.js')) %>
To get the url to your asset in PHP:
$pathToAwesomeJs = ManifestAssets::getPath('awesome.js');
Configuration
In your site config, you'll must configure a base path to your assets manifest file:
ManifestAssets: base_path: themes/awesome/dist/js
By default it looks for a manifest.json
file, but if you have a different name:
ManifestAssets: base_path: themes/awesome/dist/js file_name: assets.json
Requirements
- Silverstripe 3+
Installation
The recommended way to install is through Composer:
composer require jacobbuck/silverstripe-manifestassets