implement fullstack assets integration
This commit is contained in:
1 parent
afb8578605
commit
1c58352456
3 files changed
+12
-7
No files matched your search
@@ -40,7 +40,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||||||
..
|
..
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
let _gaurd = AssetConfigDropGaurd::new();
|
let _gaurd = WebAssetConfigDropGuard::new();
|
||||||
|
|
||||||
// start to build the assets
|
// start to build the assets
|
||||||
let ignore_files = build_assets(config)?;
|
let ignore_files = build_assets(config)?;
|
||||||
@@ -445,7 +445,7 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn gen_page(config: &CrateConfig, serve: bool) -> String {
|
pub fn gen_page(config: &CrateConfig, serve: bool) -> String {
|
||||||
let _gaurd = AssetConfigDropGaurd::new();
|
let _gaurd = WebAssetConfigDropGuard::new();
|
||||||
|
|
||||||
let crate_root = crate::cargo::crate_root().unwrap();
|
let crate_root = crate::cargo::crate_root().unwrap();
|
||||||
let custom_html_file = crate_root.join("index.html");
|
let custom_html_file = crate_root.join("index.html");
|
||||||
@@ -764,9 +764,9 @@ fn process_assets(config: &CrateConfig) -> anyhow::Result<()> {
|
|||||||
// )?)
|
// )?)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
struct AssetConfigDropGaurd;
|
pub(crate) struct WebAssetConfigDropGuard;
|
||||||
|
|
||||||
impl AssetConfigDropGaurd {
|
impl WebAssetConfigDropGuard {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// Set up the collect asset config
|
// Set up the collect asset config
|
||||||
assets_cli_support::Config::default()
|
assets_cli_support::Config::default()
|
||||||
@@ -776,7 +776,7 @@ impl AssetConfigDropGaurd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for AssetConfigDropGaurd {
|
impl Drop for WebAssetConfigDropGuard {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Reset the config
|
// Reset the config
|
||||||
assets_cli_support::Config::default().save();
|
assets_cli_support::Config::default().save();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::cfg::Platform;
|
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
use crate::plugin::PluginManager;
|
use crate::plugin::PluginManager;
|
||||||
|
use crate::{cfg::Platform, WebAssetConfigDropGuard};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -48,6 +48,8 @@ impl Build {
|
|||||||
crate::builder::build_desktop(&crate_config, false)?;
|
crate::builder::build_desktop(&crate_config, false)?;
|
||||||
}
|
}
|
||||||
Platform::Fullstack => {
|
Platform::Fullstack => {
|
||||||
|
// Fullstack mode must be built with web configs on the desktop (server) binary as well as the web binary
|
||||||
|
let _config = WebAssetConfigDropGuard::new();
|
||||||
{
|
{
|
||||||
let mut web_config = crate_config.clone();
|
let mut web_config = crate_config.clone();
|
||||||
let web_feature = self.build.client_feature;
|
let web_feature = self.build.client_feature;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
cfg::{ConfigOptsBuild, ConfigOptsServe},
|
cfg::{ConfigOptsBuild, ConfigOptsServe},
|
||||||
CrateConfig, Result,
|
CrateConfig, Result, WebAssetConfigDropGuard,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{desktop, Platform};
|
use super::{desktop, Platform};
|
||||||
@@ -12,6 +12,7 @@ pub async fn startup(config: CrateConfig, serve: &ConfigOptsServe) -> Result<()>
|
|||||||
struct FullstackPlatform {
|
struct FullstackPlatform {
|
||||||
serve: ConfigOptsServe,
|
serve: ConfigOptsServe,
|
||||||
desktop: desktop::DesktopPlatform,
|
desktop: desktop::DesktopPlatform,
|
||||||
|
_config: WebAssetConfigDropGuard,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Platform for FullstackPlatform {
|
impl Platform for FullstackPlatform {
|
||||||
@@ -32,11 +33,13 @@ impl Platform for FullstackPlatform {
|
|||||||
}
|
}
|
||||||
None => desktop_config.features = Some(vec![desktop_feature]),
|
None => desktop_config.features = Some(vec![desktop_feature]),
|
||||||
};
|
};
|
||||||
|
let config = WebAssetConfigDropGuard::new();
|
||||||
let desktop = desktop::DesktopPlatform::start(&desktop_config, serve)?;
|
let desktop = desktop::DesktopPlatform::start(&desktop_config, serve)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
desktop,
|
desktop,
|
||||||
serve: serve.clone(),
|
serve: serve.clone(),
|
||||||
|
_config: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user