diff --git a/.changeset/friendly-peas-fly.md b/.changeset/friendly-peas-fly.md new file mode 100644 index 00000000000..9065b7fcaa5 --- /dev/null +++ b/.changeset/friendly-peas-fly.md @@ -0,0 +1,5 @@ +--- +"@rspack/core": patch +--- + +fix(builtins.html): should parse `builtins.html.template` as path diff --git a/crates/rspack_plugin_html/src/plugin.rs b/crates/rspack_plugin_html/src/plugin.rs index 39b4b62714f..81b8f246df3 100644 --- a/crates/rspack_plugin_html/src/plugin.rs +++ b/crates/rspack_plugin_html/src/plugin.rs @@ -57,12 +57,14 @@ impl Plugin for HtmlPlugin { let parser = HtmlCompiler::new(config); let (content, url) = match &config.template { - Some(_template) => { - let url = parse_to_url(_template); - let resolved_template = resolve_from_context(&compilation.options.context, url.path()); + Some(template) => { + // TODO: support loader query form + let resolved_template = + resolve_from_context(&compilation.options.context, template.as_str()); + let content = fs::read_to_string(&resolved_template).context(format!( "failed to read `{}` from `{}`", - url.path(), + resolved_template.display(), &compilation.options.context.display() ))?; (content, resolved_template.to_string_lossy().to_string())