From b42576d6531215d53114843882acc5dc311a9b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 22 Jan 2021 17:11:13 +0100 Subject: [PATCH] Add Inject test case --- assets/js/main.js | 1 + assets/js/shims/process.js | 3 +++ layouts/index.html | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 assets/js/shims/process.js diff --git a/assets/js/main.js b/assets/js/main.js index 9ac34fb..f2e1809 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -20,6 +20,7 @@ window.hello2 = hello2; window.hello3 = hello3; window.hello4 = hello4; window.hello6 = hello6; +window.cwd = process.cwd; // Shim injected // TODO(bep) make this work in Hugo integration tests window.helloNodeModules = helloNodeModules; window.data = data; window.params = params; diff --git a/assets/js/shims/process.js b/assets/js/shims/process.js new file mode 100644 index 0000000..e0f77c6 --- /dev/null +++ b/assets/js/shims/process.js @@ -0,0 +1,3 @@ +export let process = { + cwd: () => 'shim cwd' +}; diff --git a/layouts/index.html b/layouts/index.html index 24c16bb..2d6357b 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -10,7 +10,8 @@ {{ end }} - {{ $js := resources.Get "js/main.js" | js.Build (dict "minify" false "params" (dict "myparam" "Hugo Rocks!") ) }} + {{ $inject := slice "js/shims/process.js" }} + {{ $js := resources.Get "js/main.js" | js.Build (dict "minify" false "params" (dict "myparam" "Hugo Rocks!") "inject" $inject ) }} {{ partialCached "jslibs/alpinejs/script-src.html" "-" }} @@ -25,6 +26,7 @@

  • +