From fcf6f35c522d4e07ada986bbd1d97db341da2c97 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 20 Jan 2025 21:17:24 +0800 Subject: [PATCH] chore(plugin-sass): rename unreleased option (#4398) --- packages/plugin-sass/src/index.ts | 9 ++++++--- packages/plugin-sass/src/types.ts | 5 +++-- website/docs/en/plugins/list/plugin-sass.mdx | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/plugin-sass/src/index.ts b/packages/plugin-sass/src/index.ts index d28ac98a19..006297d39f 100644 --- a/packages/plugin-sass/src/index.ts +++ b/packages/plugin-sass/src/index.ts @@ -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) @@ -137,8 +139,9 @@ 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; } @@ -146,8 +149,8 @@ export const pluginSass = ( 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( diff --git a/packages/plugin-sass/src/types.ts b/packages/plugin-sass/src/types.ts index d9ec1dfbe4..68cf2fe8a2 100644 --- a/packages/plugin-sass/src/types.ts +++ b/packages/plugin-sass/src/types.ts @@ -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; }; diff --git a/website/docs/en/plugins/list/plugin-sass.mdx b/website/docs/en/plugins/list/plugin-sass.mdx index a277a0038f..c9b835ff76 100644 --- a/website/docs/en/plugins/list/plugin-sass.mdx +++ b/website/docs/en/plugins/list/plugin-sass.mdx @@ -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