aboutsummaryrefslogtreecommitdiff
path: root/ui/client-scripts/build.rs
blob: fa3fcaf9058428ed9ea20193359f82affcd04de7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/
#![feature(exit_status_error)]
use std::process::{Command, Stdio};

fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    for file in glob::glob("src/**/*.ts").unwrap().map(Result::unwrap) {
        println!("cargo:rerun-if-changed={}", file.to_str().unwrap());
    }
    let outpath = std::env::var("OUT_DIR").unwrap();
    let mut proc = Command::new("esbuild")
        .arg("src/main.ts")
        .arg("--bundle")
        .arg(format!("--outfile={outpath}/bundle.js"))
        .arg("--target=esnext")
        .arg("--sourcemap")
        .arg("--format=esm")
        .stdout(Stdio::piped())
        .stderr(Stdio::piped())
        .spawn()
        .unwrap();
    proc.wait().unwrap().exit_ok().unwrap();
}