refactor: rename static folder

This commit is contained in:
Max Hohlfeld 2024-07-10 23:09:14 +02:00
parent a68a00a9bd
commit 10df91adfe
5 changed files with 34 additions and 15 deletions

4
.gitignore vendored
View File

@ -1,4 +1,4 @@
/target /target
*.db* *.db*
/static_packages/node_modules /static/node_modules
/static_packages/dist /static/dist

View File

@ -1,20 +1,39 @@
use static_files::{resource_dir, NpmBuild}; use static_files::{resource_dir, NpmBuild};
use std::{fs::{self, copy}, path::Path}; use std::{
fs::{self, copy},
path::Path,
};
fn main() -> std::io::Result<()> { fn main() -> std::io::Result<()> {
NpmBuild::new("./static_packages") NpmBuild::new("./static").change_detection().install()?;
.change_detection()
.install()?;
if fs::metadata(Path::new("./static_packages/dist")).is_err() { let dist_path = Path::new("./static/dist");
fs::create_dir(Path::new("./static_packages/dist"))?; let nm_path = Path::new("./static/node_modules");
if fs::metadata(dist_path).is_err() {
fs::create_dir(dist_path)?;
} }
copy(Path::new("./static_packages/node_modules/feather-icons/dist/feather-sprite.svg"), Path::new("./static_packages/dist/feather-sprite.svg"))?; copy(
copy(Path::new("./static_packages/node_modules/bulma/css/bulma.min.css"), Path::new("./static_packages/dist/bulma.min.css"))?; nm_path.join("feather-icons/dist/feather-sprite.svg"),
copy(Path::new("./static_packages/node_modules/htmx.org/dist/htmx.min.js"), Path::new("./static_packages/dist/htmx.min.js"))?; dist_path.join("feather-sprite.svg"),
copy(Path::new("./static_packages/node_modules/htmx.org/dist/ext/response-targets.js"), Path::new("./static_packages/dist/response-targets.js"))?; )?;
copy(Path::new("./static_packages/brass.jpeg"), Path::new("./static_packages/dist/brass.jpeg"))?; copy(
nm_path.join("bulma/css/bulma.min.css"),
dist_path.join("bulma.min.css"),
)?;
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(
Path::new("./static/brass.jpeg"),
dist_path.join("brass.jpeg"),
)?;
resource_dir("./static_packages/dist").build() resource_dir("./static/dist").build()
} }

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,5 +1,5 @@
{ {
"name": "static_packages", "name": "static",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {