From 356b9761c8dc7c32514fddc7c608f36597a9a9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jumeau?= Date: Wed, 4 Apr 2018 15:42:34 +0200 Subject: [PATCH 1/5] New section about JSON file manifest strategy @see https://symfony.com/blog/new-in-symfony-3-3-manifest-based-asset-versioning --- components/asset.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/asset.rst b/components/asset.rst index 2fdfc8d517a..1d8a6162b61 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -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 +`_, which generate 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 ......................... From f177f2fa714a27d0ac512bd0e07af9270249258b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jumeau?= Date: Thu, 19 Apr 2018 19:22:34 +0200 Subject: [PATCH 2/5] Fix typo --- components/asset.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/asset.rst b/components/asset.rst index 1d8a6162b61..50e0e911d62 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -144,7 +144,7 @@ JSON File Manifest Use the :class:`Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy` to take advantage of the strategy used by popular tools such as `Webpack -`_, which generate a JSON file mapping all source file names to their corresponding output file. For example:: +`_, which generates a JSON file mapping all source file names to their corresponding output file. For example:: // rev-manifest.json { From 423ff7389890d79f038ecf29a773e7e939d608bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jumeau?= Date: Fri, 20 Apr 2018 09:54:42 +0200 Subject: [PATCH 3/5] Link to the asset component documentation --- frontend/encore/versioning.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/encore/versioning.rst b/frontend/encore/versioning.rst index 9ba5442ef2c..1846a1507a0 100644 --- a/frontend/encore/versioning.rst +++ b/frontend/encore/versioning.rst @@ -59,3 +59,8 @@ like normal: + +Learn more +---------- + +* :doc:`/components/asset` From 57494a43a21497796518749d545a46491cc9399e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 17 May 2018 15:35:18 +0200 Subject: [PATCH 4/5] Reword --- components/asset.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/asset.rst b/components/asset.rst index 50e0e911d62..a88c98bf44e 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -142,9 +142,11 @@ string as the second argument of the ``StaticVersionStrategy`` constructor:: JSON File Manifest .................. -Use the :class:`Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy` -to take advantage of the strategy used by popular tools such as `Webpack -`_, which generates a JSON file mapping all source file names to their corresponding output file. For example:: +A popular strategy to manage asset versioning, which is used by tools such as +`Webpack`_, is to generate a JSON file mapping all source file names to their +corresponding output file: + +.. code-block:: json // rev-manifest.json { @@ -153,6 +155,8 @@ to take advantage of the strategy used by popular tools such as `Webpack "...": "..." } +In those cases, use the +:class:`Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy`:: use Symfony\Component\Asset\Package; use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy; @@ -372,3 +376,4 @@ Learn more ---------- .. _Packagist: https://packagist.org/packages/symfony/asset +.. _`Webpack`: https://webpack.js.org/ From 99d9b0c67d7db3b981a1e08e0f411c00b29a9ec0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 17 May 2018 15:35:51 +0200 Subject: [PATCH 5/5] Added a missing comma --- components/asset.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/asset.rst b/components/asset.rst index a88c98bf44e..f541048e7e4 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -151,7 +151,7 @@ corresponding output file: // rev-manifest.json { "css/app.css": "build/css/app.b916426ea1d10021f3f17ce8031f93c2.css", - "js/app.js": "build/js/app.13630905267b809161e71d0f8a0c017b.js" + "js/app.js": "build/js/app.13630905267b809161e71d0f8a0c017b.js", "...": "..." }