mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-16 21:58:25 +00:00
set the required environment variable for manganis support
This commit is contained in:
parent
663296ae45
commit
e004c1722f
20 changed files with 99 additions and 190 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -2592,7 +2592,6 @@ dependencies = [
|
|||
"futures-util",
|
||||
"global-hotkey",
|
||||
"infer 0.11.0",
|
||||
"manganis-cli-support",
|
||||
"minify-js",
|
||||
"muda",
|
||||
"objc",
|
||||
|
@ -2672,7 +2671,6 @@ dependencies = [
|
|||
"http 0.2.11",
|
||||
"http-body-util",
|
||||
"hyper 0.14.28",
|
||||
"manganis-cli-support",
|
||||
"once_cell",
|
||||
"pin-project",
|
||||
"salvo",
|
||||
|
@ -6136,7 +6134,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "manganis"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
||||
dependencies = [
|
||||
"manganis-macro",
|
||||
]
|
||||
|
@ -6144,7 +6141,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "manganis-cli-support"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo-lock 9.0.0",
|
||||
|
@ -6170,7 +6166,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "manganis-common"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.21.6",
|
||||
|
@ -6185,7 +6180,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "manganis-macro"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/DioxusLabs/collect-assets?rev=94ea6f7#94ea6f728b3d135b5160f2c119c6e797049e4b2c"
|
||||
dependencies = [
|
||||
"base64 0.21.6",
|
||||
"manganis-cli-support",
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -98,11 +98,13 @@ thiserror = "1.0.40"
|
|||
prettyplease = { package = "prettier-please", version = "0.2", features = [
|
||||
"verbatim",
|
||||
] }
|
||||
manganis-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7", features = [
|
||||
"webp",
|
||||
"html",
|
||||
] }
|
||||
manganis = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7" }
|
||||
# manganis-cli-support = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7", features = [
|
||||
# "webp",
|
||||
# "html",
|
||||
# ] }
|
||||
# manganis = { git = "https://github.com/DioxusLabs/collect-assets", rev = "94ea6f7" }
|
||||
manganis-cli-support = { path = "/Users/evanalmloff/Desktop/Github/assets/cli-support" }
|
||||
manganis = { path = "/Users/evanalmloff/Desktop/Github/assets" }
|
||||
|
||||
|
||||
# This is a "virtual package"
|
||||
|
|
|
@ -12,17 +12,14 @@ pub fn asset_manifest(crate_config: &CrateConfig) -> AssetManifest {
|
|||
}
|
||||
|
||||
/// Create a head file that contains all of the imports for assets that the user project uses
|
||||
pub fn create_assets_head(config: &CrateConfig) -> Result<()> {
|
||||
let manifest = asset_manifest(config);
|
||||
pub fn create_assets_head(config: &CrateConfig, manifest: &AssetManifest) -> Result<()> {
|
||||
let mut file = File::create(config.out_dir.join("__assets_head.html"))?;
|
||||
file.write_all(manifest.head().as_bytes())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Process any assets collected from the binary
|
||||
pub(crate) fn process_assets(config: &CrateConfig) -> anyhow::Result<()> {
|
||||
let manifest = asset_manifest(config);
|
||||
|
||||
pub(crate) fn process_assets(config: &CrateConfig, manifest: &AssetManifest) -> anyhow::Result<()> {
|
||||
let static_asset_output_dir = PathBuf::from(
|
||||
config
|
||||
.dioxus_config
|
||||
|
|
|
@ -9,7 +9,7 @@ use dioxus_cli_config::CrateConfig;
|
|||
use dioxus_cli_config::ExecutableType;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use lazy_static::lazy_static;
|
||||
use serde::Serialize;
|
||||
use manganis_cli_support::{AssetManifest, ManganisSupportGuard};
|
||||
use std::{
|
||||
fs::{copy, create_dir_all, File},
|
||||
io::Read,
|
||||
|
@ -23,10 +23,11 @@ lazy_static! {
|
|||
static ref PROGRESS_BARS: indicatif::MultiProgress = indicatif::MultiProgress::new();
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BuildResult {
|
||||
pub warnings: Vec<Diagnostic>,
|
||||
pub elapsed_time: u128,
|
||||
pub assets: Option<AssetManifest>,
|
||||
}
|
||||
|
||||
pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildResult> {
|
||||
|
@ -47,7 +48,8 @@ pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildRe
|
|||
..
|
||||
} = config;
|
||||
|
||||
let _gaurd = WebAssetConfigDropGuard::new();
|
||||
let _guard = WebAssetConfigDropGuard::new();
|
||||
let _manganis_support = ManganisSupportGuard::default();
|
||||
|
||||
// start to build the assets
|
||||
let ignore_files = build_assets(config)?;
|
||||
|
@ -261,13 +263,18 @@ pub fn build(config: &CrateConfig, _: bool, skip_assets: bool) -> Result<BuildRe
|
|||
}
|
||||
}
|
||||
|
||||
if !skip_assets {
|
||||
process_assets(config)?;
|
||||
}
|
||||
let assets = if !skip_assets {
|
||||
let assets = asset_manifest(config);
|
||||
process_assets(config, &assets)?;
|
||||
Some(assets)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(BuildResult {
|
||||
warnings: warning_messages,
|
||||
elapsed_time: t_start.elapsed().as_millis(),
|
||||
assets,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -281,6 +288,7 @@ pub fn build_desktop(
|
|||
let t_start = std::time::Instant::now();
|
||||
let ignore_files = build_assets(config)?;
|
||||
let _guard = dioxus_cli_config::__private::save_config(config);
|
||||
let _manganis_support = ManganisSupportGuard::default();
|
||||
|
||||
let mut cmd = subprocess::Exec::cmd("cargo")
|
||||
.env("CARGO_TARGET_DIR", &config.target_dir)
|
||||
|
@ -394,12 +402,16 @@ pub fn build_desktop(
|
|||
}
|
||||
}
|
||||
|
||||
if !skip_assets {
|
||||
let assets = if !skip_assets {
|
||||
let assets = asset_manifest(config);
|
||||
// Collect assets
|
||||
process_assets(config)?;
|
||||
process_assets(config, &assets)?;
|
||||
// Create the __assets_head.html file for bundling
|
||||
create_assets_head(config)?;
|
||||
}
|
||||
create_assets_head(config, &assets)?;
|
||||
Some(assets)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
log::info!(
|
||||
"🚩 Build completed: [./{}]",
|
||||
|
@ -411,6 +423,7 @@ pub fn build_desktop(
|
|||
Ok(BuildResult {
|
||||
warnings: warning_messages,
|
||||
elapsed_time: t_start.elapsed().as_millis(),
|
||||
assets,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -470,7 +483,7 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
|||
Ok(warning_messages)
|
||||
}
|
||||
|
||||
pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String {
|
||||
pub fn gen_page(config: &CrateConfig, manifest: Option<&AssetManifest>, serve: bool) -> String {
|
||||
let _gaurd = WebAssetConfigDropGuard::new();
|
||||
|
||||
let crate_root = crate_root().unwrap();
|
||||
|
@ -515,8 +528,7 @@ pub fn gen_page(config: &CrateConfig, serve: bool, skip_assets: bool) -> String
|
|||
{
|
||||
style_str.push_str("<link rel=\"stylesheet\" href=\"/{base_path}/tailwind.css\">\n");
|
||||
}
|
||||
if !skip_assets {
|
||||
let manifest = asset_manifest(config);
|
||||
if let Some(manifest) = manifest {
|
||||
style_str.push_str(&manifest.head());
|
||||
}
|
||||
|
||||
|
|
|
@ -52,12 +52,10 @@ impl Build {
|
|||
// #[cfg(feature = "plugin")]
|
||||
// let _ = PluginManager::on_build_start(&crate_config, &platform);
|
||||
|
||||
match platform {
|
||||
Platform::Web => {
|
||||
crate::builder::build(&crate_config, false, self.build.skip_assets)?;
|
||||
}
|
||||
let build_result = match platform {
|
||||
Platform::Web => crate::builder::build(&crate_config, false, self.build.skip_assets)?,
|
||||
Platform::Desktop => {
|
||||
crate::builder::build_desktop(&crate_config, false, self.build.skip_assets)?;
|
||||
crate::builder::build_desktop(&crate_config, false, self.build.skip_assets)?
|
||||
}
|
||||
Platform::Fullstack => {
|
||||
// Fullstack mode must be built with web configs on the desktop (server) binary as well as the web binary
|
||||
|
@ -87,12 +85,12 @@ impl Build {
|
|||
};
|
||||
let _gaurd =
|
||||
FullstackServerEnvGuard::new(self.build.force_debug, self.build.release);
|
||||
crate::builder::build_desktop(&desktop_config, false, self.build.skip_assets)?;
|
||||
crate::builder::build_desktop(&desktop_config, false, self.build.skip_assets)?
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let temp = gen_page(&crate_config, false, self.build.skip_assets);
|
||||
let temp = gen_page(&crate_config, build_result.assets.as_ref(), false);
|
||||
|
||||
let mut file = std::fs::File::create(
|
||||
crate_config
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use dioxus_cli_config::Platform;
|
||||
use manganis_cli_support::AssetManifest;
|
||||
|
||||
use super::*;
|
||||
use std::{fs::create_dir_all, io::Write, path::PathBuf};
|
||||
|
@ -47,9 +48,6 @@ impl Serve {
|
|||
|
||||
match platform {
|
||||
Platform::Web => {
|
||||
// generate dev-index page
|
||||
Serve::regen_dev_page(&crate_config, self.serve.skip_assets)?;
|
||||
|
||||
// start the develop server
|
||||
server::web::startup(
|
||||
self.serve.port,
|
||||
|
@ -69,8 +67,11 @@ impl Serve {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn regen_dev_page(crate_config: &CrateConfig, skip_assets: bool) -> Result<()> {
|
||||
let serve_html = gen_page(crate_config, true, skip_assets);
|
||||
pub fn regen_dev_page(
|
||||
crate_config: &CrateConfig,
|
||||
manifest: Option<&AssetManifest>,
|
||||
) -> anyhow::Result<()> {
|
||||
let serve_html = gen_page(crate_config, manifest, true);
|
||||
|
||||
let dist_path = crate_config
|
||||
.crate_dir
|
||||
|
|
|
@ -49,7 +49,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let _dioxus_config = DioxusConfig::load(Some(bin.clone()))
|
||||
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
||||
.unwrap_or_else(|| {
|
||||
log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||
log::info!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||
DioxusConfig::default()
|
||||
});
|
||||
|
||||
|
|
|
@ -111,6 +111,9 @@ pub async fn serve(
|
|||
) -> Result<()> {
|
||||
let first_build_result = crate::builder::build(&config, false, skip_assets)?;
|
||||
|
||||
// generate dev-index page
|
||||
Serve::regen_dev_page(&config, first_build_result.assets.as_ref())?;
|
||||
|
||||
log::info!("🚀 Starting development server...");
|
||||
|
||||
// WS Reload Watching
|
||||
|
@ -448,7 +451,7 @@ fn build(config: &CrateConfig, reload_tx: &Sender<()>, skip_assets: bool) -> Res
|
|||
// change the websocket reload state to true;
|
||||
// the page will auto-reload.
|
||||
if config.dioxus_config.web.watcher.reload_html {
|
||||
let _ = Serve::regen_dev_page(config, skip_assets);
|
||||
let _ = Serve::regen_dev_page(config, result.assets.as_ref());
|
||||
}
|
||||
let _ = reload_tx.send(());
|
||||
Ok(result)
|
||||
|
|
|
@ -52,8 +52,6 @@ crossbeam-channel = "0.5.8"
|
|||
tao = { version = "0.24.0", features = ["rwh_05"] }
|
||||
|
||||
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||
# This is only for debug mode, and it appears mobile does not support some packages this uses
|
||||
manganis-cli-support = { workspace = true, optional = true, features = ["webp", "html"] }
|
||||
rfd = "0.12"
|
||||
global-hotkey = "0.4.1"
|
||||
muda = "0.11.3"
|
||||
|
@ -73,7 +71,6 @@ fullscreen = ["wry/fullscreen"]
|
|||
transparent = ["wry/transparent"]
|
||||
devtools = ["wry/devtools"]
|
||||
hot-reload = ["dioxus-hot-reload"]
|
||||
collect-assets = ["manganis-cli-support"]
|
||||
gnu = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
|
|
@ -81,11 +81,6 @@ impl<P: 'static> App<P> {
|
|||
}),
|
||||
};
|
||||
|
||||
// Copy over any assets we find
|
||||
// todo - re-enable this when we have a faster way of copying assets
|
||||
#[cfg(feature = "collect-assets")]
|
||||
crate::collect_assets::copy_assets();
|
||||
|
||||
// Set the event converter
|
||||
dioxus_html::set_event_converter(Box::new(crate::events::SerializedHtmlEventConverter));
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
pub fn copy_assets() {
|
||||
#[cfg(all(
|
||||
debug_assertions,
|
||||
any(
|
||||
target_os = "windows",
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
{
|
||||
// The CLI will copy assets to the current working directory
|
||||
if std::env::var_os("DIOXUS_ACTIVE").is_some() {
|
||||
return;
|
||||
}
|
||||
use manganis_cli_support::AssetManifest;
|
||||
use manganis_cli_support::AssetManifestExt;
|
||||
use manganis_cli_support::Config;
|
||||
use std::path::PathBuf;
|
||||
let config = Config::current();
|
||||
let asset_location = config.assets_serve_location();
|
||||
let asset_location = PathBuf::from(asset_location);
|
||||
let _ = std::fs::remove_dir_all(&asset_location);
|
||||
|
||||
println!("Finding assets... (Note: if you run a dioxus desktop application with the CLI. This process will be significantly faster.)");
|
||||
let manifest = AssetManifest::load();
|
||||
let has_assets = manifest
|
||||
.packages()
|
||||
.iter()
|
||||
.any(|package| !package.assets().is_empty());
|
||||
|
||||
if has_assets {
|
||||
println!("Copying and optimizing assets...");
|
||||
manifest.copy_static_assets_to(&asset_location).unwrap();
|
||||
println!("Copied assets to {}", asset_location.display());
|
||||
} else {
|
||||
println!("No assets found");
|
||||
}
|
||||
}
|
||||
#[cfg(not(all(
|
||||
debug_assertions,
|
||||
any(
|
||||
target_os = "windows",
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
)))]
|
||||
{
|
||||
println!(
|
||||
"Skipping assets in release mode. You compile assets with the dioxus-cli in release mode"
|
||||
);
|
||||
}
|
||||
}
|
|
@ -22,9 +22,6 @@ mod shortcut;
|
|||
mod waker;
|
||||
mod webview;
|
||||
|
||||
#[cfg(feature = "collect-assets")]
|
||||
mod collect_assets;
|
||||
|
||||
// mobile shortcut is only supported on mobile platforms
|
||||
#[cfg(any(target_os = "ios", target_os = "android"))]
|
||||
mod mobile_shortcut;
|
||||
|
|
|
@ -167,7 +167,7 @@ fn module_loader(root_id: &str, headless: bool) -> String {
|
|||
)
|
||||
}
|
||||
|
||||
/// Get the assset directory, following tauri/cargo-bundles directory discovery approach
|
||||
/// Get the asset directory, following tauri/cargo-bundles directory discovery approach
|
||||
///
|
||||
/// Defaults to the current directory if no asset directory is found, which is useful for development when the app
|
||||
/// isn't bundled.
|
||||
|
|
|
@ -67,9 +67,6 @@ dioxus-hot-reload = { workspace = true }
|
|||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
web-sys = { version = "0.3.61", features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
||||
|
||||
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||
# This is only for debug mode, and it appears mobile does not support some packages this uses
|
||||
manganis-cli-support = { workspace = true, features = ["webp", "html"] }
|
||||
|
||||
[features]
|
||||
default = ["hot-reload"]
|
||||
|
|
47
packages/fullstack/dist/index.html
vendored
Normal file
47
packages/fullstack/dist/index.html
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>dioxus | ⛺</title>
|
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="UTF-8" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="main"></div>
|
||||
<script type="module">
|
||||
import init from "/./assets/dioxus/name.js";
|
||||
init("/./assets/dioxus/name_bg.wasm").then(wasm => {
|
||||
if (wasm.__wbindgen_start == undefined) {
|
||||
wasm.main();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html><script>// Dioxus-CLI
|
||||
// https://github.com/DioxusLabs/dioxus/tree/master/packages/cli
|
||||
|
||||
(function () {
|
||||
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
var url = protocol + '//' + window.location.host + '/_dioxus/ws';
|
||||
var poll_interval = 8080;
|
||||
var reload_upon_connect = () => {
|
||||
window.setTimeout(
|
||||
() => {
|
||||
var ws = new WebSocket(url);
|
||||
ws.onopen = () => window.location.reload();
|
||||
ws.onclose = reload_upon_connect;
|
||||
},
|
||||
poll_interval);
|
||||
};
|
||||
|
||||
var ws = new WebSocket(url);
|
||||
ws.onmessage = (ev) => {
|
||||
if (ev.data == "reload") {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
ws.onclose = reload_upon_connect;
|
||||
})()
|
||||
</script>
|
|
@ -276,9 +276,6 @@ where
|
|||
fn serve_static_assets(mut self, assets_path: impl Into<std::path::PathBuf>) -> Self {
|
||||
use tower_http::services::{ServeDir, ServeFile};
|
||||
|
||||
// Copy over any assets we find
|
||||
crate::collect_assets::copy_assets();
|
||||
|
||||
let assets_path = assets_path.into();
|
||||
|
||||
// Serve all files in dist folder except index.html
|
||||
|
|
|
@ -241,9 +241,6 @@ impl DioxusRouterExt for Router {
|
|||
}
|
||||
|
||||
fn serve_static_assets(mut self, assets_path: impl Into<std::path::PathBuf>) -> Self {
|
||||
// Copy over any assets we find
|
||||
crate::collect_assets::copy_assets();
|
||||
|
||||
let assets_path = assets_path.into();
|
||||
|
||||
// Serve all files in dist folder except index.html
|
||||
|
|
|
@ -187,9 +187,6 @@ pub fn serve_dioxus_application<P: Clone + serde::Serialize + Send + Sync + 'sta
|
|||
// Serve the dist folder and the index.html file
|
||||
let serve_dir = warp::fs::dir(cfg.assets_path);
|
||||
|
||||
// Copy over any assets we find
|
||||
crate::collect_assets::copy_assets();
|
||||
|
||||
connect_hot_reload()
|
||||
// First register the server functions
|
||||
.or(register_server_fns(server_fn_route))
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#[cfg(any(feature = "axum", feature = "warp", feature = "salvo"))]
|
||||
pub fn copy_assets() {
|
||||
#[cfg(all(
|
||||
debug_assertions,
|
||||
any(
|
||||
target_os = "windows",
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
))]
|
||||
{
|
||||
// The CLI will copy assets to the current working directory
|
||||
if std::env::var_os("DIOXUS_ACTIVE").is_some() {
|
||||
return;
|
||||
}
|
||||
use manganis_cli_support::AssetManifest;
|
||||
use manganis_cli_support::AssetManifestExt;
|
||||
use manganis_cli_support::Config;
|
||||
use std::path::PathBuf;
|
||||
let config = Config::current();
|
||||
let asset_location = config.assets_serve_location();
|
||||
let asset_location = PathBuf::from(asset_location);
|
||||
let _ = std::fs::remove_dir_all(&asset_location);
|
||||
|
||||
println!("Finding assets... (Note: if you run a dioxus desktop application with the CLI. This process will be significantly faster.)");
|
||||
let manifest = AssetManifest::load();
|
||||
let has_assets = manifest
|
||||
.packages()
|
||||
.iter()
|
||||
.any(|package| !package.assets().is_empty());
|
||||
|
||||
if has_assets {
|
||||
println!("Copying and optimizing assets...");
|
||||
manifest.copy_static_assets_to(&asset_location).unwrap();
|
||||
println!("Copied assets to {}", asset_location.display());
|
||||
} else {
|
||||
println!("No assets found");
|
||||
}
|
||||
}
|
||||
#[cfg(not(all(
|
||||
debug_assertions,
|
||||
any(
|
||||
target_os = "windows",
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
)
|
||||
)))]
|
||||
{
|
||||
println!(
|
||||
"Skipping assets in release mode. You compile assets with the dioxus-cli in release mode"
|
||||
);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ pub mod router;
|
|||
mod adapters;
|
||||
#[cfg(feature = "ssr")]
|
||||
pub use adapters::*;
|
||||
mod collect_assets;
|
||||
mod hooks;
|
||||
#[cfg(all(debug_assertions, feature = "hot-reload", feature = "ssr"))]
|
||||
mod hot_reload;
|
||||
|
|
Loading…
Add table
Reference in a new issue