@@ -308,4 +308,133 @@ describe('loader', () => {
308308 expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
309309 expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
310310 } ) ;
311+
312+ it ( 'should have same "contenthash" with "css-loader" and source maps' , async ( ) => {
313+ const compiler = getCompiler (
314+ './contenthash/basic-css.js' ,
315+ { } ,
316+ {
317+ output : {
318+ path : path . resolve ( __dirname , '../outputs' ) ,
319+ filename : '[name].[contenthash].bundle.js' ,
320+ chunkFilename : '[name].[contenthash].chunk.js' ,
321+ publicPath : '/webpack/public/path/' ,
322+ } ,
323+ module : {
324+ rules : [
325+ {
326+ test : / \. c s s $ / i,
327+ rules : [
328+ {
329+ loader : path . resolve ( __dirname , '../src' ) ,
330+ options : { sourceMap : true } ,
331+ } ,
332+ ] ,
333+ } ,
334+ ] ,
335+ } ,
336+ }
337+ ) ;
338+ const stats = await compile ( compiler ) ;
339+
340+ expect ( Object . keys ( stats . compilation . assets ) ) . toMatchSnapshot ( 'module' ) ;
341+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
342+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
343+ } ) ;
344+
345+ it ( 'should have same "contenthash" with "postcss-loader" and source maps' , async ( ) => {
346+ const compiler = getCompiler (
347+ './contenthash/basic-postcss.js' ,
348+ { } ,
349+ {
350+ output : {
351+ path : path . resolve ( __dirname , '../outputs' ) ,
352+ filename : '[name].[contenthash].bundle.js' ,
353+ chunkFilename : '[name].[contenthash].chunk.js' ,
354+ publicPath : '/webpack/public/path/' ,
355+ } ,
356+ module : {
357+ rules : [
358+ {
359+ test : / \. c s s $ / i,
360+ rules : [
361+ {
362+ loader : path . resolve ( __dirname , '../src' ) ,
363+ options : {
364+ sourceMap : true ,
365+ importLoaders : 1 ,
366+ } ,
367+ } ,
368+ {
369+ loader : 'postcss-loader' ,
370+ options : {
371+ plugins : ( ) => [ postcssPresetEnv ( { stage : 0 } ) ] ,
372+ sourceMap : true ,
373+ } ,
374+ } ,
375+ ] ,
376+ } ,
377+ ] ,
378+ } ,
379+ }
380+ ) ;
381+ const stats = await compile ( compiler ) ;
382+
383+ expect ( Object . keys ( stats . compilation . assets ) ) . toMatchSnapshot ( 'module' ) ;
384+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
385+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
386+ } ) ;
387+
388+ it ( 'should have same "contenthash" with "sass-loader" and source maps' , async ( ) => {
389+ const compiler = getCompiler (
390+ './contenthash/basic-sass.js' ,
391+ { } ,
392+ {
393+ output : {
394+ path : path . resolve ( __dirname , '../outputs' ) ,
395+ filename : '[name].[contenthash].bundle.js' ,
396+ chunkFilename : '[name].[contenthash].chunk.js' ,
397+ publicPath : '/webpack/public/path/' ,
398+ } ,
399+ module : {
400+ rules : [
401+ {
402+ test : / \. s [ c a ] s s $ / i,
403+ rules : [
404+ {
405+ loader : path . resolve ( __dirname , '../src' ) ,
406+ options : {
407+ sourceMap : true ,
408+ importLoaders : 1 ,
409+ } ,
410+ } ,
411+ {
412+ loader : 'postcss-loader' ,
413+ options : {
414+ plugins : ( ) => [ postcssPresetEnv ( { stage : 0 } ) ] ,
415+ sourceMap : true ,
416+ } ,
417+ } ,
418+ {
419+ loader : 'sass-loader' ,
420+ options : {
421+ // eslint-disable-next-line global-require
422+ implementation : require ( 'sass' ) ,
423+ sourceMap : true ,
424+ } ,
425+ } ,
426+ ] ,
427+ } ,
428+ ] ,
429+ } ,
430+ }
431+ ) ;
432+ const stats = await compile ( compiler ) ;
433+
434+ console . log ( stats . compilation . assets ) ;
435+
436+ expect ( Object . keys ( stats . compilation . assets ) ) . toMatchSnapshot ( 'module' ) ;
437+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
438+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
439+ } ) ;
311440} ) ;
0 commit comments