@@ -1798,6 +1798,7 @@ Each package can configure the following options:
1798
1798
* :ref: `version <reference-framework-assets-version >`
1799
1799
* :ref: `version_format <reference-assets-version-format >`
1800
1800
* :ref: `json_manifest_path <reference-assets-json-manifest-path >`
1801
+ * :ref: `strict_mode <reference-assets-strict-mode >`
1801
1802
1802
1803
.. _reference-framework-assets-version :
1803
1804
.. _ref-framework-assets-version :
@@ -2041,6 +2042,8 @@ package:
2041
2042
foo_package :
2042
2043
# this package uses its own manifest (the default file is ignored)
2043
2044
json_manifest_path : " %kernel.project_dir%/public/build/a_different_manifest.json"
2045
+ # Throws an exception when an asset is not found in the manifest
2046
+ strict_mode : %kernel.debug%
2044
2047
bar_package :
2045
2048
# this package uses the global manifest (the default file is used)
2046
2049
base_path : ' /images'
@@ -2061,9 +2064,10 @@ package:
2061
2064
<!-- you can use absolute URLs too and Symfony will download them automatically -->
2062
2065
<!-- <framework:assets json-manifest-path="https://cdn.example.com/manifest.json"> -->
2063
2066
<!-- this package uses its own manifest (the default file is ignored) -->
2067
+ <!-- Throws an exception when an asset is not found in the manifest -->
2064
2068
<framework : package
2065
2069
name =" foo_package"
2066
- json-manifest-path =" %kernel.project_dir%/public/build/a_different_manifest.json" />
2070
+ json-manifest-path =" %kernel.project_dir%/public/build/a_different_manifest.json" strict-mode = " %kernel.debug% " />
2067
2071
<!-- this package uses the global manifest (the default file is used) -->
2068
2072
<framework : package
2069
2073
name =" bar_package"
@@ -2087,7 +2091,9 @@ package:
2087
2091
// 'json_manifest_path' => 'https://cdn.example.com/manifest.json',
2088
2092
$framework->assets()->package('foo_package')
2089
2093
// this package uses its own manifest (the default file is ignored)
2090
- ->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json');
2094
+ ->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json')
2095
+ // Throws an exception when an asset is not found in the manifest
2096
+ ->setStrictMode('%kernel.debug%');
2091
2097
2092
2098
$framework->assets()->package('bar_package')
2093
2099
// this package uses the global manifest (the default file is used)
@@ -2104,11 +2110,27 @@ package:
2104
2110
2105
2111
If you request an asset that is *not found * in the ``manifest.json `` file, the original -
2106
2112
*unmodified * - asset path will be returned.
2113
+ Since Symfony 5.4, you can set ``strict_mode `` to ``true `` to get an exception when an asset is *not found *.
2107
2114
2108
2115
.. note ::
2109
2116
2110
2117
If an URL is set, the JSON manifest is downloaded on each request using the `http_client `_.
2111
2118
2119
+ .. _reference-assets-strict-mode :
2120
+
2121
+ strict_mode
2122
+ ...........
2123
+
2124
+ **type **: ``boolean `` **default **: ``false ``
2125
+
2126
+ .. versionadded :: 5.4
2127
+
2128
+ The ``strict_mode `` option was introduced in Symfony 5.4.
2129
+
2130
+ When enabled, the strict mode asserts that all requested assets are in the
2131
+ manifest file. This option is useful to detect typos or missing assets, the
2132
+ recommended value is ``%kernel.debug% ``.
2133
+
2112
2134
translator
2113
2135
~~~~~~~~~~
2114
2136
0 commit comments