svelte_parser/
lib.rs

1#![allow(unused_parens)]
2
3mod config;
4mod constants;
5mod helpers;
6mod runtime;
7
8use std::fs;
9
10use constants::{ID, NAME, PLUGIN};
11use expressrs::plugin::BasePlugin;
12use runtime::checker::check;
13use runtime::copier::{clean, copy, run};
14
15pub fn svelte() -> BasePlugin {
16    BasePlugin {
17        name: NAME.to_string(),
18        id: ID.to_string(),
19        plugin_id: PLUGIN.to_string(),
20        dist: "dist".to_string(),
21        features: None,
22        main: Box::new(|public_dir| {
23            let root_dir = env!("CARGO_MANIFEST_DIR");
24
25            clean();
26
27            check();
28            copy(public_dir, format!("{}/build/src/svelte", root_dir));
29            run();
30
31            fs::create_dir_all("dist").expect("Failed to create a dist directory");
32            copy(format!("{}/build/dist", root_dir), "dist".to_string());
33        }),
34    }
35}