File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1-
2- const withTypedCssModules = ( webpackConfig ) => {
1+ // modifies Next.js's internal webpack config to add autogenerated typings for css modules
2+ const withTypedCssModules = ( config ) => {
33 const cssLoaderRegex = / (?< ! p o s t ) c s s - l o a d e r / ;
44 const typingsForCssModulesLoader = {
55 loader : "@teamsupercell/typings-for-css-modules-loader" ,
66 options : {
77 disableLocalsExport : true ,
88 verifyOnly : process . env . NODE_ENV === "production" ,
9- banner : `// AUTOGENERATED FILE -- DO NOT EDIT DIRECTLY\n` ,
9+ banner : `// AUTOGENERATED FILE -- DO NOT EDIT DIRECTLY` . trimStart ( ) ,
1010 } ,
1111 } ;
1212
1313 // looking for the webpack rules where `css-loader` is specified
14- const { oneOf } = webpackConfig . module . rules . find ( ( rule ) => Array . isArray ( rule . oneOf ) ) ;
14+ const { oneOf } = config . module . rules . find ( ( rule ) => Array . isArray ( rule . oneOf ) ) ;
1515 const rules = oneOf . filter ( ( rule ) => Array . isArray ( rule . use ) ) ;
1616
1717 rules . forEach ( ( rule ) => {
@@ -24,9 +24,8 @@ const withTypedCssModules = (webpackConfig) => {
2424 rule . use . splice ( cssLoaderIndex , 0 , { ...typingsForCssModulesLoader } ) ;
2525 } )
2626
27- return webpackConfig
27+ return config ;
2828}
29-
3029
3130/** @type {import('next').NextConfig } */
3231module . exports = {
You can’t perform that action at this time.
0 commit comments