feat: change public to asset_dir
This commit is contained in:
1 parent
210b456838
commit
c3ba5c287d
3 files changed
+11
-11
No files matched your search
@@ -12,7 +12,7 @@ default_platform = "web"
|
|||||||
out_dir = "dist"
|
out_dir = "dist"
|
||||||
|
|
||||||
# resource (static) file folder
|
# resource (static) file folder
|
||||||
public_dir = "public"
|
asset_dir = "public"
|
||||||
|
|
||||||
[web.app]
|
[web.app]
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -22,7 +22,7 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
out_dir,
|
out_dir,
|
||||||
crate_dir,
|
crate_dir,
|
||||||
target_dir,
|
target_dir,
|
||||||
public_dir,
|
asset_dir,
|
||||||
executable,
|
executable,
|
||||||
dioxus_config,
|
dioxus_config,
|
||||||
..
|
..
|
||||||
@@ -105,8 +105,8 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
content_only: false,
|
content_only: false,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
};
|
};
|
||||||
if public_dir.is_dir() {
|
if asset_dir.is_dir() {
|
||||||
for entry in std::fs::read_dir(&public_dir)? {
|
for entry in std::fs::read_dir(&asset_dir)? {
|
||||||
let path = entry?.path();
|
let path = entry?.path();
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
std::fs::copy(&path, out_dir.join(path.file_name().unwrap()))?;
|
std::fs::copy(&path, out_dir.join(path.file_name().unwrap()))?;
|
||||||
@@ -195,7 +195,7 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> {
|
|||||||
copy(res_path, &config.out_dir.join(target_file))?;
|
copy(res_path, &config.out_dir.join(target_file))?;
|
||||||
|
|
||||||
// this code will copy all public file to the output dir
|
// this code will copy all public file to the output dir
|
||||||
if config.public_dir.is_dir() {
|
if config.asset_dir.is_dir() {
|
||||||
let copy_options = fs_extra::dir::CopyOptions {
|
let copy_options = fs_extra::dir::CopyOptions {
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
skip_exist: false,
|
skip_exist: false,
|
||||||
@@ -205,7 +205,7 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> {
|
|||||||
depth: 0,
|
depth: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
for entry in std::fs::read_dir(&config.public_dir)? {
|
for entry in std::fs::read_dir(&config.asset_dir)? {
|
||||||
let path = entry?.path();
|
let path = entry?.path();
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
std::fs::copy(&path, &config.out_dir.join(path.file_name().unwrap()))?;
|
std::fs::copy(&path, &config.out_dir.join(path.file_name().unwrap()))?;
|
||||||
|
|||||||
+5
-5
@@ -33,7 +33,7 @@ impl Default for DioxusConfig {
|
|||||||
name: "dioxus".into(),
|
name: "dioxus".into(),
|
||||||
default_platform: "web".to_string(),
|
default_platform: "web".to_string(),
|
||||||
out_dir: Some(PathBuf::from("dist")),
|
out_dir: Some(PathBuf::from("dist")),
|
||||||
public_dir: Some(PathBuf::from("public")),
|
asset_dir: Some(PathBuf::from("public")),
|
||||||
},
|
},
|
||||||
web: WebConfig {
|
web: WebConfig {
|
||||||
app: WebAppConfing {
|
app: WebAppConfing {
|
||||||
@@ -61,7 +61,7 @@ pub struct ApplicationConfig {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub default_platform: String,
|
pub default_platform: String,
|
||||||
pub out_dir: Option<PathBuf>,
|
pub out_dir: Option<PathBuf>,
|
||||||
pub public_dir: Option<PathBuf>,
|
pub asset_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@@ -101,7 +101,7 @@ pub struct CrateConfig {
|
|||||||
pub crate_dir: PathBuf,
|
pub crate_dir: PathBuf,
|
||||||
pub workspace_dir: PathBuf,
|
pub workspace_dir: PathBuf,
|
||||||
pub target_dir: PathBuf,
|
pub target_dir: PathBuf,
|
||||||
pub public_dir: PathBuf,
|
pub asset_dir: PathBuf,
|
||||||
pub manifest: cargo_toml::Manifest<cargo_toml::Value>,
|
pub manifest: cargo_toml::Manifest<cargo_toml::Value>,
|
||||||
pub executable: ExecutableType,
|
pub executable: ExecutableType,
|
||||||
pub dioxus_config: DioxusConfig,
|
pub dioxus_config: DioxusConfig,
|
||||||
@@ -130,7 +130,7 @@ impl CrateConfig {
|
|||||||
|
|
||||||
let cargo_def = &crate_dir.join("Cargo.toml");
|
let cargo_def = &crate_dir.join("Cargo.toml");
|
||||||
|
|
||||||
let public_dir = match dioxus_config.application.public_dir {
|
let asset_dir = match dioxus_config.application.asset_dir {
|
||||||
Some(ref v) => crate_dir.join(v),
|
Some(ref v) => crate_dir.join(v),
|
||||||
None => crate_dir.join("public"),
|
None => crate_dir.join("public"),
|
||||||
};
|
};
|
||||||
@@ -154,7 +154,7 @@ impl CrateConfig {
|
|||||||
crate_dir,
|
crate_dir,
|
||||||
workspace_dir,
|
workspace_dir,
|
||||||
target_dir,
|
target_dir,
|
||||||
public_dir,
|
asset_dir,
|
||||||
manifest,
|
manifest,
|
||||||
executable,
|
executable,
|
||||||
release,
|
release,
|
||||||
|
|||||||
Reference in new issue
Block a user