@@ -1879,6 +1879,7 @@ Each package can configure the following options:
1879
1879
* :ref: `version <reference-framework-assets-version >`
1880
1880
* :ref: `version_format <reference-assets-version-format >`
1881
1881
* :ref: `json_manifest_path <reference-assets-json-manifest-path >`
1882
+ * :ref: `strict_mode <reference-assets-strict-mode >`
1882
1883
1883
1884
.. _reference-framework-assets-version :
1884
1885
.. _ref-framework-assets-version :
@@ -2122,6 +2123,8 @@ package:
2122
2123
foo_package :
2123
2124
# this package uses its own manifest (the default file is ignored)
2124
2125
json_manifest_path : " %kernel.project_dir%/public/build/a_different_manifest.json"
2126
+ # Throws an exception when an asset is not found in the manifest
2127
+ strict_mode : %kernel.debug%
2125
2128
bar_package :
2126
2129
# this package uses the global manifest (the default file is used)
2127
2130
base_path : ' /images'
@@ -2142,9 +2145,10 @@ package:
2142
2145
<!-- you can use absolute URLs too and Symfony will download them automatically -->
2143
2146
<!-- <framework:assets json-manifest-path="https://cdn.example.com/manifest.json"> -->
2144
2147
<!-- this package uses its own manifest (the default file is ignored) -->
2148
+ <!-- Throws an exception when an asset is not found in the manifest -->
2145
2149
<framework : package
2146
2150
name =" foo_package"
2147
- json-manifest-path =" %kernel.project_dir%/public/build/a_different_manifest.json" />
2151
+ json-manifest-path =" %kernel.project_dir%/public/build/a_different_manifest.json" strict-mode = " %kernel.debug% " />
2148
2152
<!-- this package uses the global manifest (the default file is used) -->
2149
2153
<framework : package
2150
2154
name =" bar_package"
@@ -2168,7 +2172,9 @@ package:
2168
2172
// 'json_manifest_path' => 'https://cdn.example.com/manifest.json',
2169
2173
$framework->assets()->package('foo_package')
2170
2174
// this package uses its own manifest (the default file is ignored)
2171
- ->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json');
2175
+ ->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json')
2176
+ // Throws an exception when an asset is not found in the manifest
2177
+ ->setStrictMode('%kernel.debug%');
2172
2178
2173
2179
$framework->assets()->package('bar_package')
2174
2180
// this package uses the global manifest (the default file is used)
@@ -2190,11 +2196,26 @@ package:
2190
2196
2191
2197
If you request an asset that is *not found * in the ``manifest.json `` file, the original -
2192
2198
*unmodified * - asset path will be returned.
2199
+ Since Symfony 5.4, you can set ``strict_mode `` to ``true `` to get an exception when an asset is *not found *.
2193
2200
2194
2201
.. note ::
2195
2202
2196
2203
If an URL is set, the JSON manifest is downloaded on each request using the `http_client `_.
2197
2204
2205
+ .. _reference-assets-strict-mode :
2206
+
2207
+ strict_mode
2208
+ ...........
2209
+
2210
+ **type **: ``boolean `` **default **: ``false ``
2211
+
2212
+ When enabled, the strict mode assert that all requested assets are in the manifest file.
2213
+ This option is useful to detect typo or missing assets, the recommended value is ``%kernel.debug% ``.
2214
+
2215
+ .. versionadded :: 5.4
2216
+
2217
+ This option was introduced in Symfony 5.4.
2218
+
2198
2219
translator
2199
2220
~~~~~~~~~~
2200
2221
0 commit comments