🔧 Chore: add "Build" param for plugin script and refactor custom.js by js.build

This commit is contained in:
Cell
2022-09-23 17:10:50 +08:00
parent b50cfe0bd7
commit 64db19998f
3 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ All notable changes to this project will be documented in this file.
- :lipstick: Style: change line-break style of code element from `anywhere` to `auto`
- :globe_with_meridians: Docs(i18n): update pt-br, de in i18n
- :mag: Perf(SEO): enhance SEO performance
- :wrench: Chore: modify babel config and optimize theme.js compilation and loading
- :wrench: Chore: modify babel config and optimize theme.js compilation and loading (revert [`65371a1`](https://github.com/hugo-fixit/FixIt/commit/65371a19a40591c3f403f7fde2b7001c3390354d))
- :wrench: Chore: creating new go.mod: module github.com/hugo-fixit/FixIt
- :arrow_up: Chore(libs):
- Update simple-icons from 6.3.0 to 7.12.0
+4 -4
View File
@@ -232,9 +232,7 @@
{{- /* PWA */ -}}
{{- if .Site.Params.enablePWA | and hugo.IsProduction -}}
{{- $options := dict -}}
{{- $options = dict "targetPath" "service-worker.min.js" | merge $options -}}
{{- $options = dict "minify" true | merge $options -}}
{{- $options := dict "targetPath" "service-worker.min.js" "minify" true -}}
{{- $source := resources.Get "js/service-worker.js" | js.Build $options -}}
{{- $_ := $source.RelPermalink -}}
{{- $config = dict "enablePWA" .Site.Params.enablePWA | merge $config -}}
@@ -264,12 +262,14 @@
{{- $config | jsonify | printf "window.config=%s;" | dict "Content" | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- /* Theme script */ -}}
{{- /* TODO migrate to js.build in hugo future version */ -}}
{{- dict "Source" "js/theme.min.js" "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}
{{- /* Custom script */ -}}
{{- with ((resources.Get "js/custom.js") | default (resources.Get "js/_custom.js")) -}}
{{- dict "Source" . "Minify" hugo.IsProduction "Fingerprint" $fingerprint "Defer" true | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}}
{{- $options := dict "targetPath" "js/custom.min.js" "minify" true "sourceMap" "inline" -}}
{{- dict "Source" . "Build" $options "Fingerprint" $fingerprint "Defer" true | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}}
{{- end -}}
{{- with (.Scratch.Get "this").scriptArr -}}
+3
View File
@@ -18,6 +18,9 @@
{{- $resource = $resource | fingerprint . -}}
{{- $integrity = $resource.Data.Integrity -}}
{{- end -}}
{{- with .Build -}}
{{- $resource = $resource | js.Build . -}}
{{- end -}}
{{- $src = $resource.RelPermalink -}}
{{- end -}}
{{- $attrs := printf `src="%v"` $src -}}