This repository has been archived by the owner. It is now read-only.
Loads an asset manifest to map your assets to dynamic ones.
Switch branches/tags
Nothing to show
Clone or download
Latest commit aa27ccb Nov 29, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src add configurable prefixes Dec 22, 2016
tests add configurable prefixes Dec 22, 2016
.gitattributes initial commit Apr 19, 2016
.gitignore initial commit Apr 19, 2016
.php_cs initial commit Apr 19, 2016
.scrutinizer.yml initial commit Apr 19, 2016
.sensiolabs.yml initial commit Apr 19, 2016
.styleci.yml initial commit Apr 19, 2016
.travis.yml add configurable prefixes Dec 22, 2016
LICENSE add license Apr 19, 2016 Update Nov 29, 2017
composer.json add configurable prefixes Dec 22, 2016
phpunit.xml initial commit Apr 19, 2016

NOTE: This functionality of this bundle is now in Symfony Core.


Build Status Scrutinizer Code Quality Code Coverage SensioLabs Insight StyleCI Latest Stable Version License

This bundle adds the twig function manifest_asset that is a wrapper for the native asset but looks for a configured manifest json file to map assets. This file can be generated using Gulp and the gulp-rev Gulp plugin. If you have used Laravel with Laravel Elixir the manifest_asset function is similar to Laravel's elixir function.



composer require zenstruck/asset-manifest-bundle

Enabled bundle:

  public function registerBundles() {
      $bundles = [
          new Zenstruck\AssetManifestBundle\ZenstruckAssetManifestBundle(),


By default, no manifest is configured. In development, this is probably ideal. For production, you will want to configure a manifest file to map your assets.


    manifest_file: "%kernel.root_dir%/../web/assets/manifest.json"



asset should be replaced by manifest_asset in twig files.

Here an example:

<!DOCTYPE html>
    <title>My page title</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="{{ manifest_asset('assets/main.css') }}">
    My page content

Note: If no manifest file is configured, the manifest_asset behaves exactly like the native asset function.


Say your public (web) folder looks as follows:

├── assets
│   ├── build
│   │   ├── css
│   │   │   └── app-8f07f52635.css
│   │   └── rev-manifest.json
│   └── css
│       └── app.css

And your rev-manifest.json file looks as follows:

    "css/app.css": "css/app-8f07f52635.css"

Using the manifest_asset twig function, you would pass assets/css/app.css but this wouldn't map correctly. To fix this, you can add prefixes to your config.yml:

    manifest_file: "%kernel.root_dir%/../web/assets/build/manifest.json"
        source: assets/
        destination: assets/build/

Now, assets/css/app.css would properly map to assets/build/css/app-8f07f52635.css.

Full Default Config

    manifest_file: ~
        source: ~
        destination: ~