Skip to content

Commit

Permalink
fix: css resource cannot find sourcemap (farm-fe#714)
Browse files Browse the repository at this point in the history
* fix: css resource cannot find sourcemap

* chore: add changeset file

* fix: typo
  • Loading branch information
shulandmimi authored Nov 9, 2023
1 parent 3a5d60c commit 45761df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/late-emus-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farmfe/core': patch
---

fix css resource pot load sourcemap
7 changes: 6 additions & 1 deletion crates/compiler/src/generate/render_resource_pots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ pub fn render_resource_pots_and_generate_resources(
// to make sure the source map can be found.
if let Some(mut source_map) = res.source_map {
source_map.name = format!("{}.{}", r.name, source_map.resource_type.to_ext());
let source_mapping_url = format!("\n//# sourceMappingURL=/{}", source_map.name);

let source_mapping_url = if matches!(r.resource_type, ResourceType::Css) {
format!("\n/*# sourceMappingURL=/{} */", source_map.name)
} else {
format!("\n//# sourceMappingURL=/{}", source_map.name)
};
r.bytes.append(&mut source_mapping_url.as_bytes().to_vec());

resource_pot.add_resource(source_map.name.clone());
Expand Down

0 comments on commit 45761df

Please sign in to comment.