Skip to content

Commit

Permalink
fix: 🐛 fix parsing error in html template path (#2380)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng authored Mar 21, 2023
1 parent 97dc0dd commit 7431442
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-peas-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rspack/core": patch
---

fix(builtins.html): should parse `builtins.html.template` as path
10 changes: 6 additions & 4 deletions crates/rspack_plugin_html/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 7431442

Please sign in to comment.