diff --git a/test/__snapshots__/sourceMap-option.test.js.snap b/test/__snapshots__/sourceMap-option.test.js.snap index fd1786ba..f2e57411 100644 --- a/test/__snapshots__/sourceMap-option.test.js.snap +++ b/test/__snapshots__/sourceMap-option.test.js.snap @@ -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`] = ` diff --git a/test/sourceMap-option.test.js b/test/sourceMap-option.test.js index 0225f14c..cc15f7df 100644 --- a/test/sourceMap-option.test.js +++ b/test/sourceMap-option.test.js @@ -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'); + }); }); });