Skip to content

[StaticWebAssets] Adds fingerprinting support for assets#41092

Closed
javiercn wants to merge 71 commits intomainfrom
javiercn/static-web-asset-endpoints-fingerprints
Closed

[StaticWebAssets] Adds fingerprinting support for assets#41092
javiercn wants to merge 71 commits intomainfrom
javiercn/static-web-asset-endpoints-fingerprints

Conversation

@javiercn
Copy link
Member

@javiercn javiercn commented May 22, 2024

Adds support for fingerprinting assets

  • Fingerprinting works by defining expressions on the RelativePath of assets.
  • Expressions contain tokens like [.{fingerprint}] which allow us to define replacements that need to happen as part of the build.
  • Expressions might result in more than one endpoint if they are marked as optional with either ? or !. These modifiers determine how the file is addressable in standalone scenarios.
    • ? signifies that the file will not have its name replaced to add the expression.
    • ! signifies that the file will have its name replaced to add the expression.
  • Expressions can contain embedded values via {.fingerprint=value} syntax, which makes it so that value takes precedence when reducing the expression to its literal form.
  • The expressions are retained through the build until the last moment when we replace them with values to produce the final path/routes. This allows us to refer to assets/endpoints logically through the build.
  • Any endpoint with a replaced value on its route, gets assigned a 'label' in its properties as well as the values that were replaced on the expression used to define that endpoint.
    • The label is the endpoint path without any token expression.
    • The replaced values are the list of values that were applied to the route.
    • The combination of label + values allows the endpoint to be uniquely identified with a human-addressable name.

Scoped CSS

  • Scoped CSS asset project bundles are updated to fingerprint the file and offer the non-fingerprinted endpoint with [.{fingerprint}]!.bundle.scp.css
  • Scoped CSS app bundles are updated to offer a fingerprinted endpoint with [.{fingerprint}.styles.css
  • ConcatenateCss is updated to rely on endpoints.
  • Three new tasks help working with endpoints.
    • FilterStaticWebAssetEndpoints to filter a list of endpoints based on a configurable set of criteria.
    • UpdateStaticWebAssetEndpoints to modify a header, property, or selector of a group of endpoints. Options are RemoveAll, Remove, Append, Replace.
    • ResolveEndpointRoutes to produce the final URL that can be used on Tasks that need to consume the endpoint path

@ghost ghost added Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, StaticWebAssetsSDK untriaged Request triage from a team member labels May 22, 2024
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @javiercn.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

@javiercn javiercn force-pushed the javiercn/static-web-asset-endpoints-fingerprints branch 2 times, most recently from 944ebbb to 4e6c33d Compare May 22, 2024 20:26
@javiercn javiercn force-pushed the javiercn/static-web-asset-endpoints-fingerprints branch 3 times, most recently from c3a1873 to 212e6b5 Compare May 24, 2024 10:14
@javiercn javiercn marked this pull request as ready for review May 24, 2024 22:31
@javiercn javiercn requested review from a team as code owners May 24, 2024 22:31
@javiercn javiercn force-pushed the javiercn/static-web-asset-endpoints-fingerprints branch 2 times, most recently from a7ec11c to d14e842 Compare May 28, 2024 00:20
@javiercn javiercn force-pushed the javiercn/static-web-asset-endpoints-fingerprints branch from 2b6bfc9 to c620d1d Compare May 28, 2024 14:05
@javiercn
Copy link
Member Author

javiercn commented Jun 4, 2024

Closing in favor of #41244

@javiercn javiercn closed this Jun 4, 2024
@akoeplinger akoeplinger deleted the javiercn/static-web-asset-endpoints-fingerprints branch March 18, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, StaticWebAssetsSDK untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant