Skip to content

[Asset] Add option $strictMode to JsonManifestVersionStrategy #14414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Oct 14, 2020

Documentation for symfony/symfony#38495

@javiereguiluz javiereguiluz added the Waiting Code Merge Docs for features pending to be merged label Oct 17, 2020
@GromNaN GromNaN changed the title [Asset] Add option $strict to JsonManifestVersionStrategy [Asset] Add option $strictMoe to JsonManifestVersionStrategy Jan 30, 2021
@GromNaN GromNaN changed the title [Asset] Add option $strictMoe to JsonManifestVersionStrategy [Asset] Add option $strictMode to JsonManifestVersionStrategy Jan 30, 2021
@GromNaN GromNaN force-pushed the assets-strict branch 2 times, most recently from 973798b to 3ab23be Compare February 17, 2021 13:38
@carsonbot carsonbot added this to the next milestone May 26, 2021
@javiereguiluz javiereguiluz modified the milestones: next, 5.4 May 26, 2021
fabpot added a commit to symfony/symfony that referenced this pull request Jul 25, 2021
…missing item (GromNaN)

This PR was merged into the 5.4 branch.

Discussion
----------

[Asset] [DX] Option to make asset manifests strict on missing item

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#14414

In all the projects I use a JSON manifest, when an asset is not listed in manifest.json, the asset file is not generated. The current behavior is permissive as it returns the unmodified path of the asset. Which ends with a 404 when the browser tries to load the asset.

With the option `strict_mode: true`, an exception is thrown when we try to use an asset that is not listed in `manifest.json`. Thereby we don't have to check that asset urls are actually working in tests (manual or automated).

**Usage:**
The option `strict_mode` is optional for backward compatibility. Using the `%kernel.debug%` value is safe to flush bugs on dev or test mode but keep the application working on production.

```yaml
# config/packages/assets.yaml

framework:
    assets:
        packages:
            app:
                # Uses a JSON manifest (can be a local path or an url remote file)
                json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
                # Throws an exception when an expected entry is missing in the manifest
                strict_mode: '%kernel.debug%'

```

Todo:
- [x] Documentation symfony/symfony-docs#14414
- [x] Demo symfony/demo#1168
- [x] ~Update recipe ?~

Commits
-------

4cdb921 Option to make asset manifests strict on missing item
@javiereguiluz
Copy link
Member

This been pending for too long. Apart from the rebase, is there anything else to be done to make this mergeable? Thanks!

@GromNaN
Copy link
Member Author

GromNaN commented Dec 13, 2021

I rebased an updated the doc according to the version it was merged.

@javiereguiluz javiereguiluz removed the Waiting Code Merge Docs for features pending to be merged label Dec 13, 2021
@javiereguiluz javiereguiluz merged commit dd89fe0 into symfony:5.4 Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants