Skip to content

Commit

Permalink
Add Inject test case
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 22, 2021
1 parent a3dd790 commit b42576d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 3 additions & 0 deletions assets/js/shims/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export let process = {
cwd: () => 'shim cwd'
};
4 changes: 3 additions & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
{{ 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 ) }}
<script src="{{ $js.RelPermalink }}"></script>
{{ partialCached "jslibs/alpinejs/script-src.html" "-" }}
</head>
Expand All @@ -25,6 +26,7 @@ <h2>
<li x-text="hello3()"></li>
<li x-text="hello4()"></li>
<li x-text="hello6()"></li>
<li x-text="cwd()"></li>
<!--li x-text="helloNodeModules()"></li-->
<li x-text="data.Hugo"></li>
<li x-text="params.myparam"></li>
Expand Down

0 comments on commit b42576d

Please sign in to comment.