Skip to content

Commit

Permalink
chore(plugin-sass): rename unreleased option (#4398)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jan 20, 2025
1 parent 4f9650e commit fcf6f35
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions packages/plugin-sass/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export const pluginSass = (
true,
);

const { rewriteUrls = true } = pluginOptions;

const ruleId = findRuleId(chain, CHAIN_ID.RULE.SASS);
const rule = chain.module
.rule(ruleId)
Expand Down Expand Up @@ -137,17 +139,18 @@ export const pluginSass = (

if (id === CHAIN_ID.USE.CSS) {
// add resolve-url-loader
if (!pluginOptions.useOriginalUrlResolver)
if (rewriteUrls) {
clonedOptions.importLoaders += 1;
}
// add sass-loader
clonedOptions.importLoaders += 1;
}

rule.use(id).loader(loader.get('loader')).options(clonedOptions);
}

// use resolve-url-loader if useOriginalResolver is not set
if (!pluginOptions.useOriginalUrlResolver)
// use `resolve-url-loader` to rewrite urls
if (rewriteUrls)
rule
.use(CHAIN_ID.USE.RESOLVE_URL)
.loader(
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-sass/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export type PluginSassOptions = {
exclude?: Rspack.RuleSetCondition;

/**
* Use original url resolver instead of resolve-url-loader.
* Whether to use `resolve-url-loader` to rewrite urls.
* @default true
*/
useOriginalUrlResolver?: boolean;
rewriteUrls?: boolean;
};
6 changes: 3 additions & 3 deletions website/docs/en/plugins/list/plugin-sass.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ pluginSass({
});
```

### useOriginalUrlResolver
### rewriteUrls

- **Type:** `boolean`
- **Default:** `undefined`
- **Default:** `true`
- **Version:** `>= 1.2.0`

Use the original resolver instead of `resolve-url-loader` when resolving urls
Whether to use `resolve-url-loader` to rewrite urls.

## Practices

Expand Down

1 comment on commit fcf6f35

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
plugins ✅ success
rspress ✅ success
rslib ✅ success
examples ✅ success

Please sign in to comment.