Skip to content

Commit 3ef51fc

Browse files
jeremyjumeaujaviereguiluz
authored andcommitted
1 parent 2e820e6 commit 3ef51fc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

components/asset.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,29 @@ string as the second argument of the ``StaticVersionStrategy`` constructor::
139139
echo $package->getUrl('image.png');
140140
// result: v1/image.png
141141

142+
JSON File Manifest
143+
..................
144+
145+
Use the :class:`Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy`
146+
to take advantage of the strategy used by popular tools such as `Webpack
147+
<https://webpack.js.org/>`_, which generate a JSON file mapping all source file names to their corresponding output file. For example::
148+
149+
// rev-manifest.json
150+
{
151+
"css/app.css": "build/css/app.b916426ea1d10021f3f17ce8031f93c2.css",
152+
"js/app.js": "build/js/app.13630905267b809161e71d0f8a0c017b.js"
153+
"...": "..."
154+
}
155+
156+
157+
use Symfony\Component\Asset\Package;
158+
use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy;
159+
160+
$package = new Package(new JsonManifestVersionStrategy(__DIR__'./rev-manifest.json'));
161+
162+
echo $package->getUrl('css/app.css');
163+
// result: build/css/app.b916426ea1d10021f3f17ce8031f93c2.css
164+
142165
Custom Version Strategies
143166
.........................
144167

0 commit comments

Comments
 (0)