Skip to content

New section about JSON file manifest strategy #9548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions components/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,29 @@ string as the second argument of the ``StaticVersionStrategy`` constructor::
echo $package->getUrl('image.png');
// result: v1/image.png

JSON File Manifest
..................

Use the :class:`Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy`
to take advantage of the strategy used by popular tools such as `Webpack
<https://webpack.js.org/>`_, which generates a JSON file mapping all source file names to their corresponding output file. For example::

// rev-manifest.json
{
"css/app.css": "build/css/app.b916426ea1d10021f3f17ce8031f93c2.css",
"js/app.js": "build/js/app.13630905267b809161e71d0f8a0c017b.js"
"...": "..."
}


use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy;

$package = new Package(new JsonManifestVersionStrategy(__DIR__'./rev-manifest.json'));

echo $package->getUrl('css/app.css');
// result: build/css/app.b916426ea1d10021f3f17ce8031f93c2.css

Custom Version Strategies
.........................

Expand Down
5 changes: 5 additions & 0 deletions frontend/encore/versioning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ like normal:
<script src="{{ asset('build/app.js') }}"></script>

<link href="{{ asset('build/dashboard.css') }}" rel="stylesheet" />

Learn more
----------

* :doc:`/components/asset`