Skip to content

Commit

Permalink
do not apply sass loader on existing loaders (#50308)
Browse files Browse the repository at this point in the history
follow up for #50259

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
  • Loading branch information
sokra and jridgewell committed May 25, 2023
1 parent 06f505c commit 46369f5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/next-swc/crates/next-core/src/sass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ pub async fn maybe_add_sass_loader(
};

if let Some(rule) = rule {
// Without `as`, loader result would be JS code, so we don't want to apply
// sass-loader on that.
let Some(rename_as) = rule.rename_as.as_ref() else {
continue;
};
// Only when the result should run through the sass pipeline, we apply
// sass-loader.
if rename_as != "*" {
continue;
}
let mut loaders = rule.loaders.await?.clone_value();
loaders.push(loader);
rule.loaders = WebpackLoaderItemsVc::cell(loaders);
if let Some(rename_as) = rule.rename_as.as_mut() {
rename_as.push_str(rename);
} else {
rule.rename_as = Some(format!("*{rename}"));
}
} else {
rules.insert(
pattern.to_string(),
Expand Down

0 comments on commit 46369f5

Please sign in to comment.