Skip to content
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: 9 additions & 0 deletions packages/plugin-sass/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ const getSassLoaderOptions = (
mergeFn,
});

if (
mergedOptions.api === 'legacy' &&
!mergedOptions.sassOptions?.silenceDeprecations
) {
// mute the noisy legacy API deprecation warnings
mergedOptions.sassOptions ||= {};
mergedOptions.sassOptions.silenceDeprecations = ['legacy-js-api'];
}

return {
options: mergedOptions,
excludes,
Expand Down
62 changes: 62 additions & 0 deletions packages/plugin-sass/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,65 @@ exports[`plugin-sass > should add sass-loader with excludes 1`] = `
},
]
`;

exports[`plugin-sass > should allow to use legacy API and mute deprecation warnings 1`] = `
[
{
"resolve": {
"preferRelative": true,
},
"sideEffects": true,
"test": /\\\\\\.s\\(\\?:a\\|c\\)ss\\$/,
"use": [
{
"loader": "<ROOT>/node_modules/<PNPM_INNER>/@rspack/core/dist/builtin-plugin/css-extract/loader.js",
},
{
"loader": "<ROOT>/packages/core/compiled/css-loader/index.js",
"options": {
"importLoaders": 3,
"modules": {
"auto": true,
"exportGlobals": false,
"exportLocalsConvention": "camelCase",
"localIdentName": "[path][name]__[local]-[hash:base64:6]",
"namedExport": false,
},
"sourceMap": false,
},
},
{
"loader": "builtin:lightningcss-loader",
"options": {
"targets": [
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
},
{
"loader": "<ROOT>/packages/plugin-sass/compiled/resolve-url-loader/index.js",
"options": {
"join": [Function],
"sourceMap": false,
},
},
{
"loader": "<ROOT>/packages/plugin-sass/compiled/sass-loader/index.js",
"options": {
"api": "legacy",
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass-embedded/dist/lib/index.js",
"sassOptions": {
"silenceDeprecations": [
"legacy-js-api",
],
},
"sourceMap": true,
},
},
],
},
]
`;
17 changes: 17 additions & 0 deletions packages/plugin-sass/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,21 @@ describe('plugin-sass', () => {
const bundlerConfigs = await rsbuild.initConfigs();
expect(matchRules(bundlerConfigs[0], 'a.scss')).toMatchSnapshot();
});

it('should allow to use legacy API and mute deprecation warnings', async () => {
const rsbuild = await createRsbuild({
rsbuildConfig: {
plugins: [
pluginSass({
sassLoaderOptions: {
api: 'legacy',
},
}),
],
},
});

const bundlerConfigs = await rsbuild.initConfigs();
expect(matchRules(bundlerConfigs[0], 'a.scss')).toMatchSnapshot();
});
});
Loading