Current section

Files

Jump to
live_vue lib tasks configure_esbuild.ex
Raw

lib/tasks/configure_esbuild.ex

defmodule Mix.Tasks.LiveVue.ConfigureEsbuild do
@moduledoc """
Creates Javascript files to be used by esbuild. Necessary for LiveVue to work.
"""
import LiveVue.Logger
def run(_) do
log_info("-- Configuring esbuild...")
Mix.Project.deps_paths(depth: 1)
|> Map.fetch!(:live_vue)
|> Path.join("assets/copy/**/*.{js,json}")
|> Path.wildcard()
|> Enum.each(fn full_path ->
[_beginning, relative_path] = String.split(full_path, "copy", parts: 2)
Mix.Generator.copy_file(full_path, "assets" <> relative_path)
end)
Mix.Generator.create_directory("assets/vue")
end
end