build.rs 852 B

1234567891011121314151617181920212223242526
  1. #[cfg(not(feature = "dev-server"))]
  2. extern crate tauri_includedir_codegen;
  3. pub fn main() {
  4. #[cfg(not(feature = "dev-server"))]
  5. {
  6. println!(
  7. "cargo:rerun-if-changed={}",
  8. std::env::var("TAURI_DIST_DIR").expect("Unable to read dist directory")
  9. );
  10. match std::env::var("TAURI_DIST_DIR") {
  11. Ok(dist_path) => {
  12. let inlined_assets = match std::env::var("TAURI_INLINED_ASSETS") {
  13. Ok(assets) => assets.split("|").map(|s| s.to_string()).collect(),
  14. Err(_) => Vec::new(),
  15. };
  16. // include assets
  17. tauri_includedir_codegen::start("ASSETS")
  18. .dir(dist_path, tauri_includedir_codegen::Compression::None)
  19. .build("data.rs", inlined_assets)
  20. .expect("failed to build data.rs")
  21. }
  22. Err(e) => panic!("Build error: Couldn't find ENV: {}", e),
  23. }
  24. }
  25. }