You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NextJS already exposes defaultLoaders.babel, which can be used as follows to allow transpilation of soures outside the baseDir (in Monorepos):
module.exports=withBundleAnalyzer({webpack: (config,options)=>{// To allow transpiling aliasesconfig.module.rules.push({test: /\.+(js|jsx|mjs|ts|tsx)$/,use: options.defaultLoaders.babel,include: Object.values(aliases),});returnconfig;},});
Given the built-in support for CSS/SCSS in NextJS, full support for monorepo setup will require to allow importing css/scss (in addition to js/ts) files from directories outside the baseDir.
// Support CSS modules + global in node_modules// TODO ask Next.js maintainer to expose the css-loader via defaultLoadersconstnextCssLoaders=config.module.rules.find((rule)=>typeofrule.oneOf==='object');// .module.cssif(nextCssLoaders){constnextCssLoader=nextCssLoaders.oneOf.find((rule)=>rule.sideEffects===false&®exEqual(rule.test,/\.module\.css$/));constnextSassLoader=nextCssLoaders.oneOf.find((rule)=>rule.sideEffects===false&®exEqual(rule.test,/\.module\.(scss|sass)$/));if(nextCssLoader){nextCssLoader.issuer.or=nextCssLoader.issuer.and ? nextCssLoader.issuer.and.concat(matcher) : matcher;deletenextCssLoader.issuer.not;deletenextCssLoader.issuer.and;}else{console.warn('next-transpile-modules - could not find default CSS rule, CSS imports may not work');}if(nextSassLoader){nextSassLoader.issuer.or=nextSassLoader.issuer.and ? nextSassLoader.issuer.and.concat(matcher) : matcher;deletenextSassLoader.issuer.not;deletenextSassLoader.issuer.and;}else{console.warn('next-transpile-modules - could not find default SASS rule, SASS imports may not work');}}
Describe the feature you'd like to request
NextJS already exposes
defaultLoaders.babel
, which can be used as follows to allow transpilation of soures outside the baseDir (in Monorepos):Given the built-in support for CSS/SCSS in NextJS, full support for monorepo setup will require to allow importing css/scss (in addition to js/ts) files from directories outside the baseDir.
The issue with current workaround
The current way next-transpile-modules does it, is horribly hacky (@martpie):
Describe the solution you'd like
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: