Created
September 2, 2023 02:58
-
-
Save jmooring/95306dc46b8cfd1d69d82118a8e4ee64 to your computer and use it in GitHub Desktop.
Hugo - Transpile, tree shake, and minify JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ with resources.Get "js/main.js" }} | |
{{ if eq hugo.Environment "development" }} | |
{{ with . | js.Build }} | |
<script src="{{ .RelPermalink }}"></script> | |
{{ end }} | |
{{ else }} | |
{{ $opts := dict "minify" true }} | |
{{ with . | js.Build $opts | fingerprint }} | |
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script> | |
{{ end }} | |
{{ end }} | |
{{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment