Skip to content

Instantly share code, notes, and snippets.

@yungblud
Forked from PhilippMolitor/craco.config.js
Created March 3, 2022 03:49
Show Gist options
  • Select an option

  • Save yungblud/dd6b8434d95c3b7ee4780b875d34523d to your computer and use it in GitHub Desktop.

Select an option

Save yungblud/dd6b8434d95c3b7ee4780b875d34523d to your computer and use it in GitHub Desktop.
Fix including yarn workspaces packages in create-react-app with craco
module.exports = {
webpack: {
configure: (webpackConfig) => ({
...webpackConfig,
module: {
...webpackConfig.module,
rules: webpackConfig.module.rules.map((rule) => {
if (!rule.oneOf) return rule;
return {
...rule,
oneOf: rule.oneOf.map((ruleObject) => {
if (
!new RegExp(ruleObject.test).test('.ts') ||
!ruleObject.include
)
return ruleObject;
return { ...ruleObject, include: undefined };
}),
};
}),
},
}),
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment