Skip to content

Commit

Permalink
perf(plugin-sass): defaults to sass-embedded and modern API (#2408)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored May 22, 2024
1 parent 2574e15 commit 2fcd6b9
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/plugin-rem/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ exports[`plugin-rem > should run rem plugin with default config 1`] = `
{
"loader": "<ROOT>/packages/plugin-sass/compiled/sass-loader/index.js",
"options": {
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass/sass.node.js",
"api": "modern-compiler",
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass-embedded/dist/lib/index.js",
"sourceMap": true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@rsbuild/shared": "workspace:*",
"postcss": "^8.4.38",
"sass": "^1.77.1"
"sass-embedded": "^1.77.2"
},
"devDependencies": {
"@rsbuild/core": "workspace:*",
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-sass/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const getSassLoaderOptions = (
const mergedOptions = mergeChainedOptions({
defaults: {
sourceMap: isUseCssSourceMap,
implementation: require.resolve('sass'),
api: 'modern-compiler',
implementation: require.resolve('sass-embedded'),
},
options: userOptions,
utils: { addExcludes },
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-sass/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ChainedConfigWithUtils, FileFilterUtil } from '@rsbuild/shared';
import type {
LegacyOptions as LegacySassOptions,
Options as SassOptions,
} from 'sass';
} from 'sass-embedded';
import type SassLoader from '../compiled/sass-loader/index.js';

export type SassLoaderOptions = Omit<SassLoader.Options, 'sassOptions'> &
Expand All @@ -12,7 +12,7 @@ export type SassLoaderOptions = Omit<SassLoader.Options, 'sassOptions'> &
sassOptions?: Partial<LegacySassOptions<'async'>>;
}
| {
api: 'modern';
api: 'modern' | 'modern-compiler';
sassOptions?: SassOptions<'async'>;
}
);
Expand Down
9 changes: 6 additions & 3 deletions packages/plugin-sass/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ exports[`plugin-sass > should add sass-loader 1`] = `
{
"loader": "<ROOT>/packages/plugin-sass/compiled/sass-loader/index.js",
"options": {
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass/sass.node.js",
"api": "modern-compiler",
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass-embedded/dist/lib/index.js",
"sourceMap": true,
},
},
Expand Down Expand Up @@ -149,7 +150,8 @@ exports[`plugin-sass > should add sass-loader and css-loader when injectStyles 1
{
"loader": "<ROOT>/packages/plugin-sass/compiled/sass-loader/index.js",
"options": {
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass/sass.node.js",
"api": "modern-compiler",
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass-embedded/dist/lib/index.js",
"sourceMap": true,
},
},
Expand Down Expand Up @@ -229,7 +231,8 @@ exports[`plugin-sass > should add sass-loader with excludes 1`] = `
{
"loader": "<ROOT>/packages/plugin-sass/compiled/sass-loader/index.js",
"options": {
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass/sass.node.js",
"api": "modern-compiler",
"implementation": "<ROOT>/node_modules/<PNPM_INNER>/sass-embedded/dist/lib/index.js",
"sourceMap": true,
},
},
Expand Down
230 changes: 225 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2fcd6b9

Please sign in to comment.