-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
87 lines (77 loc) · 2.89 KB
/
build.rs
File metadata and controls
87 lines (77 loc) · 2.89 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use fs_extra::dir::{CopyOptions, copy};
use std::{fs, path::Path, process::Command};
fn main() {
// Clear the Assets directory
if Path::new("assets/").exists() {
fs::remove_dir_all("assets/").expect("Failed to remove the assets directory");
}
// Create Assets directory
fs::create_dir_all("assets/").expect("Failed to create assets directory");
// Install Node Dependencies
let output = Command::new("sh")
.arg("-c")
.arg("npm clean-install")
.output()
.expect("Failed to execute \"npm clean-install\" command");
// Ensure Node Install worked
if !output.status.success() {
panic!(
"npm clean-install failed: {}",
String::from_utf8_lossy(&output.stderr)
);
}
// Copy all images to assets working folder
fs::create_dir_all("assets/images/").expect("Failed to create assets/images directory");
copy(
"images/",
"assets/",
&CopyOptions {
overwrite: true,
..CopyOptions::default()
},
)
.expect("Failed to copy images directory to assets");
// Populate Assets directory with HTMX
fs::create_dir_all("assets/htmx").expect("Failed to create assets/htmx directory");
fs::copy(
"node_modules/htmx.org/dist/htmx.min.js",
"assets/htmx/htmx.min.js",
)
.expect("Failed to copy htmx.min.js from node_modules");
// Populate Assets directory with Viz-JS
fs::create_dir_all("assets/viz").expect("Failed to create assets/viz directory");
fs::copy(
"node_modules/@viz-js/viz/dist/viz-global.js",
"assets/viz/viz-global.js",
)
.expect("Failed to copy viz-global.js from node_modules");
// Populate Assets directory with Prism.js
fs::create_dir_all("assets/prism").expect("Failed to create assets/prism directory");
fs::copy("node_modules/prismjs/prism.js", "assets/prism/prism.js")
.expect("Failed to copy prism.js from node_modules");
fs::copy(
"node_modules/prismjs/components/prism-json.js",
"assets/prism/prism-json.js",
)
.expect("Failed to copy prism-json.js from node_modules");
fs::copy(
"node_modules/prism-themes/themes/prism-holi-theme.min.css",
"assets/prism/prism.css",
)
.expect("Failed to copy prism-holi-theme.css from node_modules");
// Generate TailwindCSS file
fs::create_dir_all("assets/tailwindcss")
.expect("Failed to create assets/tailwindcss directory");
let output = Command::new("sh")
.arg("-c")
.arg("npx @tailwindcss/cli -i ./tailwind.css -o ./assets/tailwindcss/tailwind.css --minify")
.output()
.expect("Failed to execute TailwindCSS build command");
// Ensure TailwindCSS worked
if !output.status.success() {
panic!(
"TailwindCSS build failed: {}",
String::from_utf8_lossy(&output.stderr)
);
}
}