SymfonyWorld Online 2021 Winter Edition December 9 – 10, 2021 100% Online 25 talks and 10 workshops

New in Symfony 5.1: Remote asset manifest

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

Contributed by
Jérôme Tamarelle
in #35762.

Webpack Encore is a pure-JavaScript library developed by Symfony as a simpler way to integrate Webpack into your application. When building assets, Webpack Encore creates a manifest.json file listing all the generated assets (and their versioning).

In Symfony 5.1, we've improved this feature to allow using manifest files stored in other servers and retrieved via HTTP requests. This is useful when using CDNs (content delivery networks) to serve your assets.

You don't need to add or enable any option to use this new feature. Just update the value of your existing json_manifest_path option and use an absolute URL. Symfony will make an HTTP request automatically to retrieve the manifest:

1
2
3
4
# config/packages/assets.yaml
framework:
    assets:
        json_manifest_path: 'https://cdn.example.com/manifest.json'
Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.

Comments

Typo: to server -> to serve
Fixed! Thanks Massimiliano!
GG @gromnan
This feature has been inspired by how we use manifests to deploy assets shared across every PrismaMedia's websites.

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.