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