mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-16 05:38:26 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
1017c87e9b
2 changed files with 16 additions and 5 deletions
|
@ -10,7 +10,11 @@
|
||||||
<div id="main"></div>
|
<div id="main"></div>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init from "./assets/dioxus/{app_name}.js";
|
import init from "./assets/dioxus/{app_name}.js";
|
||||||
init("./assets/dioxus/{app_name}_bg.wasm");
|
init("./assets/dioxus/{app_name}_bg.wasm").then(wasm => {
|
||||||
|
if (wasm.__wbindgen_start == undefined) {
|
||||||
|
wasm.main();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{script_include}
|
{script_include}
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -35,6 +35,7 @@ impl Default for DioxusConfig {
|
||||||
out_dir: Some(PathBuf::from("dist")),
|
out_dir: Some(PathBuf::from("dist")),
|
||||||
asset_dir: Some(PathBuf::from("public")),
|
asset_dir: Some(PathBuf::from("public")),
|
||||||
tools: None,
|
tools: None,
|
||||||
|
sub_package: None,
|
||||||
},
|
},
|
||||||
web: WebConfig {
|
web: WebConfig {
|
||||||
app: WebAppConfing {
|
app: WebAppConfing {
|
||||||
|
@ -64,6 +65,7 @@ pub struct ApplicationConfig {
|
||||||
pub out_dir: Option<PathBuf>,
|
pub out_dir: Option<PathBuf>,
|
||||||
pub asset_dir: Option<PathBuf>,
|
pub asset_dir: Option<PathBuf>,
|
||||||
pub tools: Option<HashMap<String, toml::Value>>
|
pub tools: Option<HashMap<String, toml::Value>>
|
||||||
|
pub sub_package: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -121,7 +123,11 @@ impl CrateConfig {
|
||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
let dioxus_config = DioxusConfig::load()?;
|
let dioxus_config = DioxusConfig::load()?;
|
||||||
|
|
||||||
let crate_dir = crate::cargo::crate_root()?;
|
let crate_dir = if let Some(package) = &dioxus_config.application.sub_package {
|
||||||
|
crate::cargo::crate_root()?.join(package)
|
||||||
|
} else {
|
||||||
|
crate::cargo::crate_root()?
|
||||||
|
};
|
||||||
let meta = crate::cargo::Metadata::get()?;
|
let meta = crate::cargo::Metadata::get()?;
|
||||||
let workspace_dir = meta.workspace_root;
|
let workspace_dir = meta.workspace_root;
|
||||||
let target_dir = meta.target_directory;
|
let target_dir = meta.target_directory;
|
||||||
|
@ -143,9 +149,10 @@ impl CrateConfig {
|
||||||
// We just assume they're using a 'main.rs'
|
// We just assume they're using a 'main.rs'
|
||||||
// Anyway, we've already parsed the manifest, so it should be easy to change the type
|
// Anyway, we've already parsed the manifest, so it should be easy to change the type
|
||||||
let output_filename = manifest
|
let output_filename = manifest
|
||||||
.lib
|
.bin
|
||||||
.as_ref()
|
.first()
|
||||||
.and_then(|lib| lib.name.clone())
|
.or(manifest.lib.as_ref())
|
||||||
|
.and_then(|product| product.name.clone())
|
||||||
.or_else(|| manifest.package.as_ref().map(|pkg| pkg.name.clone()))
|
.or_else(|| manifest.package.as_ref().map(|pkg| pkg.name.clone()))
|
||||||
.expect("No lib found from cargo metadata");
|
.expect("No lib found from cargo metadata");
|
||||||
let executable = ExecutableType::Binary(output_filename);
|
let executable = ExecutableType::Binary(output_filename);
|
||||||
|
|
Loading…
Add table
Reference in a new issue