I’m trying to write a custom Kino.JS module to interface with a bunch of JS packages of mine. However, whenever I try to use assets_path
with Kino.JS
, it tells me it cannot find any asset files:
warning: assets directory specified for MyModule, but no files found in "/lib/assets"
Here is a MRE:
lib/mymodule.ex
defmodule MyModule do
@moduledoc false
use Kino.JS, assets_path: "/lib/assets" # <- rel & abs paths don't work either
def new(s) do
Kino.JS.new(__MODULE__, s)
end
end
lib/assets/main.js
export function init(ctx, s) {
ctx.root.innerHTML = s
}
I have tried relative paths, absolute pahts and, finally, I looked into a couple Kino integrations and gave lib
a shot, but it doesn’t work either.
Am I missing something very obvious?
SOLVED
After checking out the assets-related functions in the Kino.JS’s source code, I came to the conclusion the problem was on my side. After trying a few things out, I realized all my paths were wrong and pointing to nothing. In fact, the following works:
use Kino.JS, assets_path: Path.expand("./lib/assets")