@@ -1879,6 +1879,7 @@ Each package can configure the following options:
18791879*:ref: `version <reference-framework-assets-version >`
18801880*:ref: `version_format <reference-assets-version-format >`
18811881*:ref: `json_manifest_path <reference-assets-json-manifest-path >`
1882+ *:ref: `strict_mode <reference-assets-strict-mode >`
18821883
18831884.. _reference-framework-assets-version :
18841885.. _ref-framework-assets-version :
@@ -2122,6 +2123,8 @@ package:
21222123foo_package :
21232124# this package uses its own manifest (the default file is ignored)
21242125json_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%
21252128bar_package :
21262129# this package uses the global manifest (the default file is used)
21272130base_path :' /images'
@@ -2142,9 +2145,10 @@ package:
21422145<!-- you can use absolute URLs too and Symfony will download them automatically-->
21432146<!-- <framework:assets json-manifest-path="https://cdn.example.com/manifest.json">-->
21442147<!-- this package uses its own manifest (the default file is ignored)-->
2148+ <!-- Throws an exception when an asset is not found in the manifest-->
21452149 <framework : package
21462150name =" 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% " />
21482152<!-- this package uses the global manifest (the default file is used)-->
21492153 <framework : package
21502154name =" bar_package"
@@ -2168,7 +2172,9 @@ package:
21682172 // 'json_manifest_path' => 'https://cdn.example.com/manifest.json',
21692173 $framework->assets()->package('foo_package')
21702174 // 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%');
21722178
21732179 $framework->assets()->package('bar_package')
21742180 // this package uses the global manifest (the default file is used)
@@ -2190,11 +2196,26 @@ package:
21902196
21912197 If you request an asset that is *not found * in the ``manifest.json `` file, the original -
21922198 *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 *.
21932200
21942201..note ::
21952202
21962203 If an URL is set, the JSON manifest is downloaded on each request using the `http_client `_.
21972204
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+
21982219translator
21992220~~~~~~~~~~
22002221