Skip to content

Do not include hash in new file name when copying fingerprinted resource #12270

@jmooring

Description

@jmooring
{{ with resources.Get "js/main.js" }}
  {{ with . | js.Build | fingerprint }}
    {{ with resources.Copy "js/app.js" . }}
      <script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
    {{ end }}
  {{ end }}
{{ end }}

With v0.124.0 this produces:

public/
└── js/
    └── app.2d2fb238b88df5e3661f42dabe45da44808e5fca65a179399fb9b5b55a243680.js

It would be convenient (and maybe make more sense) if it did this instead...

public/
└── js/
    └── app.js

...but there may be some sites in the wild that depend on the current behavior.


Stupid trick... with v0.122.0 you could do a noop with the resource .Name, .Title, or .Key to trigger the desired behavior.

{{ with resources.Get "js/main.js" }}
  {{ with . | js.Build | fingerprint }}
    {{ $noop := .Name }}
    {{ with resources.Copy "js/app.js" . }}
      <script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
    {{ end }}
  {{ end }}
{{ end }}

EDIT: Looks like you can use the same trick with v0.124.0, so I'm not sure if this feature is a bug or an enhancement. Seems like the former given the above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions