I’m using js.Build
to build/transpile my TypeScript files into JavaScript:
{{- $jsBuildOptions := newScratch -}}
{{- if hugo.IsProduction -}}
{{- $jsBuildOptions.Set "minify" true -}}
{{- else -}}
{{- $jsBuildOptions.Set "sourceMap" "inline" -}}
{{- end -}}
{{- with resources.Get . | js.Build $jsBuildOptions.Values | fingerprint -}}
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}"></script>
{{- end -}}
This block is a partial named js.html
and is used like this:
{{ partial "js.html" "ts/main.ts" }}
Now, if I introduce an error in main.ts
(like calling an unknown function), Hugo still happily builds the site.
Is there a way to convince Hugo to fail if there are TypeScript errors?
Project for reference: https://github.com/skrysmanski/devlog-theme