diff --git a/content/en/functions/js/Build.md b/content/en/functions/js/Build.md index 56118213f..3e78e8e98 100644 --- a/content/en/functions/js/Build.md +++ b/content/en/functions/js/Build.md @@ -28,31 +28,37 @@ The `js.Build` function uses the [evanw/esbuild] package to: ```go-html-template {{ with resources.Get "js/main.js" }} - {{ if hugo.IsDevelopment }} - {{ with . | js.Build }} + {{ $opts := dict + "minify" hugo.IsProduction + "sourceMap" (cond hugo.IsProduction "" "external") + "targetPath" "js/main.js" + }} + {{ with . | js.Build $opts }} + {{ if hugo.IsProduction }} + {{ with . | fingerprint }} + + {{ end }} + {{ else }} {{ end }} - {{ else }} - {{ $opts := dict "minify" true }} - {{ with . | js.Build $opts | fingerprint }} - - {{ end }} {{ end }} {{ end }} ``` ## Options -targetPath -: (`string`) If not set, the source path will be used as the base target path. +###### targetPath + +(`string`) If not set, the source path will be used as the base target path. Note that the target path's extension may change if the target MIME type is different, e.g. when the source is TypeScript. -format -: (`string`) The output format. One of: `iife`, `cjs`, `esm`. Default is `iife`, a self-executing function, suitable for inclusion as a `