Hashless assets (#4312)

* add support for external assets

* fix playwright tests

* add more documentation to with_hash_suffix

* restore external asset hashing tests

* Update gtk workflow dependencies

* fix doc test

* multiple versions of libgtk

* clear dx in playwright tests

* fix fullstack caching test

* try without apt cache

* cache everything except libxdo-dev

* revert ci changes

* fix wasm asset options

* fix merge conflict

* recommend the used attribute instead

* Move options to AssetOptionsBuilder

* Don't deprecate non-canonical new asset options functions

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2025-06-30 19:21:49 -07:00
1 parent 0bd376b873
commit e74c838441
22 files changed
+569 -316

No files matched your search

+17 -9
View File
@@ -327,7 +327,8 @@ use dioxus_cli_config::{APP_TITLE_ENV, ASSET_ROOT_ENV};
use dioxus_cli_opt::{process_file_to, AssetManifest};
use itertools::Itertools;
use krates::{cm::TargetKind, NodeId};
use manganis::{AssetOptions, JsAssetOptions};
use manganis::AssetOptions;
use manganis_core::AssetVariant;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
@@ -3310,7 +3311,7 @@ impl BuildRequest {
writeln!(
glue, "export const __wasm_split_load_chunk_{idx} = makeLoad(\"/assets/{url}\", [], fusedImports);",
url = assets
.register_asset(&path, AssetOptions::Unknown)?.bundled_path(),
.register_asset(&path, AssetOptions::builder().into_asset_options())?.bundled_path(),
)?;
}
@@ -3338,7 +3339,8 @@ impl BuildRequest {
// Again, register this wasm with the asset system
url = assets
.register_asset(&path, AssetOptions::Unknown)?.bundled_path(),
.register_asset(&path, AssetOptions::builder().into_asset_options())?
.bundled_path(),
// This time, make sure to write the dependencies of this chunk
// The names here are again, hardcoded in wasm-split - fix this eventually.
@@ -3386,7 +3388,10 @@ impl BuildRequest {
if self.should_bundle_to_asset() {
// Make sure to register the main wasm file with the asset system
assets.register_asset(&post_bindgen_wasm, AssetOptions::Unknown)?;
assets.register_asset(
&post_bindgen_wasm,
AssetOptions::builder().into_asset_options(),
)?;
}
// Now that the wasm is registered as an asset, we can write the js glue shim
@@ -3396,7 +3401,10 @@ impl BuildRequest {
// Register the main.js with the asset system so it bundles in the snippets and optimizes
assets.register_asset(
&self.wasm_bindgen_js_output_file(),
AssetOptions::Js(JsAssetOptions::new().with_minify(true).with_preload(true)),
AssetOptions::js()
.with_minify(true)
.with_preload(true)
.into_asset_options(),
)?;
}
@@ -4034,22 +4042,22 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{
// Inject any resources from manganis into the head
for asset in assets.assets() {
let asset_path = asset.bundled_path();
match asset.options() {
AssetOptions::Css(css_options) => {
match asset.options().variant() {
AssetVariant::Css(css_options) => {
if css_options.preloaded() {
head_resources.push_str(&format!(
"<link rel=\"preload\" as=\"style\" href=\"/{{base_path}}/assets/{asset_path}\" crossorigin>"
))
}
}
AssetOptions::Image(image_options) => {
AssetVariant::Image(image_options) => {
if image_options.preloaded() {
head_resources.push_str(&format!(
"<link rel=\"preload\" as=\"image\" href=\"/{{base_path}}/assets/{asset_path}\" crossorigin>"
))
}
}
AssetOptions::Js(js_options) => {
AssetVariant::Js(js_options) => {
if js_options.preloaded() {
head_resources.push_str(&format!(
"<link rel=\"preload\" as=\"script\" href=\"/{{base_path}}/assets/{asset_path}\" crossorigin>"