Skip to content
Draft
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
18 changes: 18 additions & 0 deletions e2e/cases/source-map/basic/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path, { join } from 'node:path';
import {
type Build,
expect,
findFile,
getFileContent,
mapSourceMapPositions,
test,
Expand Down Expand Up @@ -168,6 +169,7 @@ test('should generate source maps only for CSS files', async ({ build }) => {
const rsbuild = await build({
config: {
output: {
filenameHash: false,
sourceMap: {
js: false,
css: true,
Expand All @@ -186,4 +188,20 @@ test('should generate source maps only for CSS files', async ({ build }) => {
);
expect(jsMapPaths.length).toEqual(0);
expect(cssMapFiles.length).toBeGreaterThan(0);

const cssSourceMap = findFile(files, 'index.css.map');
const cssSourceContent = readFileSync(
join(__dirname, './src/index.css'),
'utf-8',
);

expect(JSON.parse(files[cssSourceMap])).toEqual({
file: 'static/css/index.css',
// cspell: disable-next-line
mappings: 'AADA',
names: [],
sources: ['../../../src/index.css'],
sourcesContent: [cssSourceContent],
version: 3,
});
});
1 change: 1 addition & 0 deletions packages/core/src/plugins/sourceMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const pluginSourceMap = (): RsbuildPlugin => ({
{
test: /\.css$/,
filename: '[file].map[query]',
moduleFilenameTemplate: sourceMapFilenameTemplate,
},
]);
}
Expand Down
Loading