1- const ExtractCssChunks = require ( 'extract-css-chunks-webpack-plugin' ) ;
2- const findUp = require ( 'find-up' ) ;
3- const OptimizeCssAssetsWebpackPlugin = require ( 'optimize-css-assets-webpack-plugin' ) ;
1+ const ExtractCssChunks = require ( 'extract-css-chunks-webpack-plugin' )
2+ const findUp = require ( 'find-up' )
3+ const OptimizeCssAssetsWebpackPlugin = require ( 'optimize-css-assets-webpack-plugin' )
44
5- const fileExtensions = new Set ( ) ;
6- let extractCssInitialized = false ;
5+ const fileExtensions = new Set ( )
6+ let extractCssInitialized = false
77
88module . exports = (
99 config ,
@@ -19,7 +19,7 @@ module.exports = (
1919) => {
2020 // We have to keep a list of extensions for the splitchunk config
2121 for ( const extension of extensions ) {
22- fileExtensions . add ( extension ) ;
22+ fileExtensions . add ( extension )
2323 }
2424
2525 if ( ! isServer && config . optimization . splitChunks . cacheGroups ) {
@@ -28,58 +28,55 @@ module.exports = (
2828 test : new RegExp ( `\\.+(${ [ ...fileExtensions ] . join ( '|' ) } )$` ) ,
2929 chunks : 'all' ,
3030 enforce : true
31- } ;
31+ }
3232 }
3333
3434 if ( ! isServer && ! extractCssInitialized ) {
3535 config . plugins . push (
3636 new ExtractCssChunks ( {
3737 // Options similar to the same options in webpackOptions.output
3838 // both options are optional
39- filename : dev
40- ? 'static/chunks/[name].css'
41- : 'static/chunks/[name].[contenthash:8].css' ,
42- chunkFilename : dev
43- ? 'static/chunks/[name].chunk.css'
44- : 'static/chunks/[name].[contenthash:8].chunk.css' ,
39+ filename : 'static/chunks/[name].[contenthash:8].css' ,
40+ chunkFilename : 'static/chunks/[name].[contenthash:8].chunk.css' ,
41+ orderWarning : true ,
4542 hot : dev
4643 } )
47- ) ;
48- extractCssInitialized = true ;
44+ )
45+ extractCssInitialized = true
4946 }
5047
5148 if ( ! dev ) {
5249 if ( ! Array . isArray ( config . optimization . minimizer ) ) {
53- config . optimization . minimizer = [ ] ;
50+ config . optimization . minimizer = [ ]
5451 }
5552 config . optimization . minimizer . push (
5653 new OptimizeCssAssetsWebpackPlugin ( {
5754 cssProcessorOptions : {
5855 discardComments : { removeAll : true }
5956 }
6057 } )
61- ) ;
58+ )
6259 }
6360
6461 const postcssConfig = findUp . sync ( 'postcss.config.js' , {
6562 cwd : config . context
66- } ) ;
67- let postcssLoader ;
63+ } )
64+ let postcssLoader
6865
6966 if ( postcssConfig ) {
7067 // Copy the postcss-loader config options first.
7168 const postcssOptionsConfig = Object . assign (
7269 { } ,
7370 postcssLoaderOptions . config ,
7471 { path : postcssConfig }
75- ) ;
72+ )
7673
7774 postcssLoader = {
7875 loader : 'postcss-loader' ,
7976 options : Object . assign ( { } , postcssLoaderOptions , {
8077 config : postcssOptionsConfig
8178 } )
82- } ;
79+ }
8380 }
8481
8582 const cssLoader = {
@@ -97,16 +94,16 @@ module.exports = (
9794 } ,
9895 cssLoaderOptions
9996 )
100- } ;
97+ }
10198
10299 // When not using css modules we don't transpile on the server
103100 if ( isServer && ! cssLoader . options . modules ) {
104- return [ 'ignore-loader' ] ;
101+ return [ 'ignore-loader' ]
105102 }
106103
107104 // When on the server and using css modules we transpile the css
108105 if ( isServer && cssLoader . options . modules ) {
109- return [ cssLoader , postcssLoader , ...loaders ] . filter ( Boolean ) ;
106+ return [ cssLoader , postcssLoader , ...loaders ] . filter ( Boolean )
110107 }
111108
112109 return [
@@ -115,5 +112,5 @@ module.exports = (
115112 cssLoader ,
116113 postcssLoader ,
117114 ...loaders
118- ] . filter ( Boolean ) ;
119- } ;
115+ ] . filter ( Boolean )
116+ }
0 commit comments