From 5b8de24beb679d46b67806cdc43cb103b584ff29 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Fri, 5 Jul 2024 11:46:25 +0200 Subject: [PATCH] Optimize dev experience for different targets --- .gitignore | 1 + Cargo.toml | 21 +++++++++++++++++---- src/main.rs | 12 +++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf7..66e0fb16 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/wasm diff --git a/Cargo.toml b/Cargo.toml index 3fbf4831..cb1797f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,25 @@ [package] -name = "bevy_github_ci_template" +name = "bevy_template" version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0 OR CC0-1.0" +[dependencies] +bevy = "0.14.0" + +[target.'cfg(target_family = "wasm")'.dependencies] +wasm-bindgen = "0.2" + +# The following block tweaks Bevy's features according to our build environment + +[dev-dependencies.bevy] +version = "0.14.0" +features = ["dynamic_linking"] + +[target.'cfg(not(target_family = "wasm"))'.dev-dependencies.bevy] +version = "0.14.0" +features = ["file_watcher", "embedded_watcher"] + # Compile with Performance Optimizations: # https://bevyengine.org/learn/book/getting-started/setup/#compile-with-performance-optimizations @@ -14,6 +30,3 @@ opt-level = 1 # Enable high optimizations for dependencies (incl. Bevy), but not for our code: [profile.dev.package."*"] opt-level = 3 - -[dependencies] -bevy = "0.12" diff --git a/src/main.rs b/src/main.rs index 895a257a..de3b0fbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,11 +11,13 @@ use bevy::prelude::*; fn main() { App::new() - // Wasm builds will check for meta files (that don't exist) if this isn't set. - // This causes errors and even panics on web build on itch. - // See https://github.com/bevyengine/bevy_github_ci_template/issues/48. - .insert_resource(AssetMetaCheck::Never) - .add_plugins(DefaultPlugins) + .add_plugins(DefaultPlugins.set(AssetPlugin { + // Wasm builds will check for meta files (that don't exist) if this isn't set. + // This causes errors and even panics on web build on itch. + // See https://github.com/bevyengine/bevy_github_ci_template/issues/48. + meta_check: AssetMetaCheck::Never, + ..default() + })) .add_systems(Startup, setup) .run(); }