jacobbuck/silverstripe-manifestassets

There is no license information available for the latest version (1.0.0) of this package.

Get the path of an asset from a generated assets manifest file.

Installs: 5 415

Dependents: 0

Suggesters: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

Type:silverstripe-module

1.0.0 2017-05-26 01:03 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