Skip to content

chore(plugin-sass): rename unreleased option #4398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading