brass/web/build.rs
2025-06-09 14:09:07 +02:00

66 lines
1.7 KiB
Rust

use change_detection::ChangeDetection;
use static_files::{resource_dir, NpmBuild};
use std::{
fs::{self, copy},
path::Path,
};
fn main() -> std::io::Result<()> {
ChangeDetection::path("static/utils.js")
.path("static/style.scss")
.path("static/brass.jpeg")
.path("static/package.json")
.generate();
built::write_built_file().expect("Failed to acquire build-time information");
NpmBuild::new("./static").install()?.run("build-bulma")?;
let dist_path = Path::new("./static/dist");
let nm_path = Path::new("./static/node_modules");
let static_path = Path::new("./static");
if fs::metadata(dist_path).is_err() {
fs::create_dir(dist_path)?;
}
copy(
nm_path.join("feather-icons/dist/feather-sprite.svg"),
dist_path.join("feather-sprite.svg"),
)?;
copy(
nm_path.join("htmx.org/dist/htmx.min.js"),
dist_path.join("htmx.min.js"),
)?;
copy(
nm_path.join("htmx.org/dist/ext/response-targets.js"),
dist_path.join("response-targets.js"),
)?;
copy(
nm_path.join("sweetalert2-neutral/dist/sweetalert2.min.js"),
dist_path.join("sweetalert2.min.js"),
)?;
copy(
nm_path.join("hyperscript.org/dist/_hyperscript.min.js"),
dist_path.join("_hyperscript.min.js"),
)?;
let static_files = vec![
"utils.js",
"brass.jpeg",
"android-chrome-192x192.png",
"android-chrome-512x512.png",
"apple-touch-icon.png",
"favicon-16x16.png",
"favicon-32x32.png",
"favicon.ico",
"site.webmanifest",
];
for file in static_files {
copy(static_path.join(file), dist_path.join(file))?;
}
resource_dir("./static/dist").build()
}