-
DescriptionA minimal working example is available at https://github.com/rgaiacs/quarto-minimal-site I'm working on a extension that provides some JavaScript that loads some modules, i.e. import { f } from "./lib.js"; For over simplification, the HTML template has <script src="_extensions/minimal/static/main.js" defer="defer"></script> <script src="site_libs/quarto-contrib/quarto-project/minimal/static/main.js" defer="defer"> Quarto parses a intermediate HTML, identifies the asset ( Any solution? I tried https://quarto.org/docs/websites/website-tools.html#site-resources but the files are copied to another location. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Why not use the native dependencies handling from Quarto extension? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help. I updated the minimal working example. The function from Quarto's Lua API that I was needed to know is function Meta(m)
quarto.doc.add_html_dependency({
name = "minimal",
version = "1.0.0",
scripts = {
{ path = "../static/main.js", attribs = { type = "module" } }
},
})
quarto.doc.attach_to_dependency("minimal", "../static/lib.js")
end The content of
and <head>
<script src="site_libs/quarto-contrib/minimal-1.0.0/main.js" type="module"></script>
</head> |
Beta Was this translation helpful? Give feedback.
Let's fix your example:
main.js
is wrong: there are no "f" function exported, only the default functionBoth scripts need to have the module type:
resources
should be removed.And it works:
The HTML is: