This repository has been archived on 2024-06-16. You can view files and clone it, but cannot push or open issues or pull requests.
mebe/lib/mix/tasks/frontend.watch.ex
2017-04-04 07:29:47 +03:00

51 lines
1,013 B
Elixir

defmodule Mix.Tasks.Frontend.Watch do
use MBU.BuildTask
import MBU.TaskUtils
alias Mix.Tasks.Frontend.Build.Js.Transpile, as: TranspileJS
alias Mix.Tasks.Frontend.Build.Js.Bundle, as: BundleJS
alias Mix.Tasks.Frontend.Build.Js.Copy, as: CopyJS
alias Mix.Tasks.Frontend.Build.Css.Compile, as: CompileCSS
alias Mix.Tasks.Frontend.Build.Css.Copy, as: CopyCSS
@shortdoc "Watch frontend and rebuild when necessary"
@deps [
"frontend.build"
]
task _ do
[
exec(
TranspileJS.bin(),
TranspileJS.args() ++ ["-w"]
),
watch(
"JSBundle",
TranspileJS.out_path(),
BundleJS
),
watch(
"JSCopy",
BundleJS.out_path(),
CopyJS
),
exec(
CompileCSS.bin(),
CompileCSS.args() ++ [
"-w",
CompileCSS.scss_file()
]
),
watch(
"CSSCopy",
CompileCSS.out_path(),
CopyCSS
)
]
|> listen(watch: true)
end
end