Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b3c977e

Browse filesBrowse files
committed
document new framework.assets.json_manifest_path option
1 parent a95f4f0 commit b3c977e
Copy full SHA for b3c977e

File tree

2 files changed

+102
-3
lines changed
Filter options

2 files changed

+102
-3
lines changed

‎frontend/custom_version_strategy.rst

Copy file name to clipboardExpand all lines: frontend/custom_version_strategy.rst
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ applications by adding a version identifier to the URL of the static assets
1010
identifier is also modified to force the browser to download it again instead of
1111
reusing the cached asset.
1212

13-
Symfony supports asset versioning thanks to the :ref:`version <reference-framework-assets-version>`
14-
and :ref:`version_format <reference-assets-version-format>` configuration
13+
Symfony supports asset versioning thanks to the
14+
:ref:`version <reference-framework-assets-version>`,
15+
:ref:`version_format <reference-assets-version-format>`, and
16+
:ref:`json_manifest_path <reference-assets-json-manifest-path>` configuration
1517
options. If your application requires a more advanced versioning, such as
1618
generating the version dynamically based on some external information, you can
1719
create your own version strategy.

‎reference/configuration/framework.rst

Copy file name to clipboardExpand all lines: reference/configuration/framework.rst
+98-1Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Configuration
7171
* `version_strategy`_
7272
* `version`_
7373
* `version_format`_
74+
* `json_manifest_path`_
7475
* `templating`_
7576
* `hinclude_default_template`_
7677
* :ref:`form <reference-templating-form>`
@@ -980,6 +981,7 @@ Each package can configure the following options:
980981
* :ref:`version_strategy <reference-assets-version-strategy>`
981982
* :ref:`version <reference-framework-assets-version>`
982983
* :ref:`version_format <reference-assets-version-format>`
984+
* :ref:`json_manifest_path <reference-assets-json-manifest-path>`
983985

984986
.. _reference-framework-assets-version:
985987
.. _ref-framework-assets-version:
@@ -1187,7 +1189,100 @@ individually for each asset package:
11871189
11881190
.. note::
11891191

1190-
This parameter cannot be set at the same time as ``version``.
1192+
This parameter cannot be set at the same time as ``version`` or ``json_manifest_path``.
1193+
1194+
.. _reference-assets-json-manifest-path:
1195+
.. _reference-templating-json-manifest-path:
1196+
1197+
json_manifest_path
1198+
..................
1199+
1200+
**type**: ``string`` **default**: ``null``
1201+
1202+
.. versionadded:: 3.3
1203+
1204+
The ``json_manifest_path`` option was introduced in Symfony 3.3.
1205+
1206+
The file path to a ``manifest.json`` file containing an associative array of asset
1207+
names and their respective compiled names. A common cache-busting technique using
1208+
a ``manifest.json`` file works by writing out assets with a "hash" appended to their
1209+
file names (e.g. ``main.ae433f1cb.css``). You can incorporate this into many work
1210+
flows, including Webpack and Gulp using `webpack-manifest-plugin`_ and `gulp-rev`_,
1211+
respectfully.
1212+
1213+
This option can be set globally for all assets and individually for each asset
1214+
package:
1215+
1216+
.. configuration-block::
1217+
1218+
.. code-block:: yaml
1219+
1220+
# app/config/config.yml
1221+
framework:
1222+
assets:
1223+
# this manifest is applied to every asset (including packages)
1224+
json_manifest_path: "%kernel.project_dir%/web/assets/manifest.json"
1225+
packages:
1226+
foo_package:
1227+
# this package uses its own manifest (the default file is ignored)
1228+
json_manifest_path: "%kernel.project_dir%/web/assets/a_different_manifest.json"
1229+
bar_package:
1230+
# this package uses the global manifest (the default file is used)
1231+
base_path: '/images'
1232+
1233+
.. code-block:: xml
1234+
1235+
<!-- app/config/config.xml -->
1236+
<?xml version="1.0" encoding="UTF-8" ?>
1237+
<container xmlns="http://symfony.com/schema/dic/services"
1238+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1239+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1240+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
1241+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1242+
1243+
<framework:config>
1244+
<framework:assets json_manifest_path="%kernel.project_dir%/web/assets/manifest.json">
1245+
<!-- this package removes the manifest (the file will not apply) -->
1246+
<framework:package
1247+
name="foo_package"
1248+
json_manifest_path="%kernel.project_dir%/web/assets/a_different_manifest.json" />
1249+
<!-- this package uses the global manifest (the default file is used) -->
1250+
<framework:package
1251+
name="bar_package"
1252+
base_path="/images" />
1253+
</framework:assets>
1254+
</framework:config>
1255+
</container>
1256+
1257+
.. code-block:: php
1258+
1259+
// app/config/config.php
1260+
$container->loadFromExtension('framework', array(
1261+
'assets' => array(
1262+
'json_manifest_path' => '%kernel.project_dir%/web/assets/manifest.json',
1263+
'packages' => array(
1264+
'foo_package' => array(
1265+
// this package uses its own manifest (the default file is ignored)
1266+
'json_manifest_path' => '%kernel.project_dir%/web/assets/a_different_manifest.json',
1267+
),
1268+
'bar_package' => array(
1269+
// this package uses the global manifest (the default file is used)
1270+
'json_manifest_path' => '/images',
1271+
),
1272+
),
1273+
),
1274+
));
1275+
1276+
.. note::
1277+
1278+
This parameter cannot be set at the same time as ``version`` or ``version_strategy``.
1279+
Additionally, this option cannot be nullified at the package scope if a global manifest
1280+
file is specified.
1281+
1282+
.. tip::
1283+
1284+
If you request an asset that is *not found* in the ``manifest.json`` file, the original -
1285+
*unmodified* - asset path will be returned.
11911286

11921287
templating
11931288
~~~~~~~~~~
@@ -1901,3 +1996,5 @@ Full Default Configuration
19011996
.. _`PhpStormProtocol`: https://github.com/aik099/PhpStormProtocol
19021997
.. _`phpstorm-url-handler`: https://github.com/sanduhrs/phpstorm-url-handler
19031998
.. _`blue/green deployment`: http://martinfowler.com/bliki/BlueGreenDeployment.html
1999+
.. _`gulp-rev`: https://www.npmjs.com/package/gulp-rev
2000+
.. _`webpack-manifest-plugin`: https://www.npmjs.com/package/webpack-manifest-plugin

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.