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
16 changes: 16 additions & 0 deletions test/__snapshots__/sourceMap-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"sourceMap" option false should generate source maps when css was extracted: errors 1`] = `Array []`;

exports[`"sourceMap" option false should generate source maps when css was extracted: extracted css 1`] = `
".nested {
color: blue;
}

.class {
color: red;
}

"
`;

exports[`"sourceMap" option false should generate source maps when css was extracted: warnings 1`] = `Array []`;

exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: errors 1`] = `Array []`;

exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: module 1`] = `
Expand Down
43 changes: 43 additions & 0 deletions test/sourceMap-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,5 +742,48 @@ describe('"sourceMap" option', () => {
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it('should generate source maps when css was extracted', async () => {
const compiler = getCompiler(
'./source-map/basic.js',
{},
{
output: {
path: path.resolve(__dirname, '../outputs'),
filename: '[name].bundle.js',
chunkFilename: '[name].chunk.js',
publicPath: '/webpack/public/path/',
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
module: {
rules: [
{
test: /\.css$/i,
rules: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: path.resolve(__dirname, '../src'),
options: { sourceMap: false },
},
],
},
],
},
}
);
const stats = await compile(compiler);

expect(readAsset('main.css', compiler, stats)).toMatchSnapshot(
'extracted css'
);
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});
});
});