fix(core): do not embed assets on dev when using a URL (#8739)

This commit is contained in:
Lucas Fernandes Nogueira 2024-02-03 08:18:59 -03:00 committed by GitHub
parent cb613beea6
commit 0a01b5b720
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 82 deletions

View File

@ -157,30 +157,34 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
options = options.with_csp();
}
let assets = match &config.build.frontend_dist {
Some(url) => match url {
FrontendDist::Url(_url) => Default::default(),
FrontendDist::Dist(path) => {
let assets_path = config_parent.join(path);
if !assets_path.exists() {
panic!(
"The `frontendDist` configuration is set to `{:?}` but this path doesn't exist",
path
)
let assets = if dev && config.build.dev_url.is_some() {
Default::default()
} else {
match &config.build.frontend_dist {
Some(url) => match url {
FrontendDist::Url(_url) => Default::default(),
FrontendDist::Dist(path) => {
let assets_path = config_parent.join(path);
if !assets_path.exists() {
panic!(
"The `frontendDist` configuration is set to `{:?}` but this path doesn't exist",
path
)
}
EmbeddedAssets::new(assets_path, &options, map_core_assets(&options, target))?
}
EmbeddedAssets::new(assets_path, &options, map_core_assets(&options, target))?
}
FrontendDist::Files(files) => EmbeddedAssets::new(
files
.iter()
.map(|p| config_parent.join(p))
.collect::<Vec<_>>(),
&options,
map_core_assets(&options, target),
)?,
_ => unimplemented!(),
},
None => Default::default(),
FrontendDist::Files(files) => EmbeddedAssets::new(
files
.iter()
.map(|p| config_parent.join(p))
.collect::<Vec<_>>(),
&options,
map_core_assets(&options, target),
)?,
_ => unimplemented!(),
},
None => Default::default(),
}
};
let out_dir = {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html lang="en" theme="dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>API Example App</title>
<script type="module" crossorigin src="/assets/index.js"></script>
<link rel="stylesheet" href="/assets/index.css">
</head>
<body>
<div id="app"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB