Skip to content

Commit

Permalink
fix: Add support for CRACO 7 and CRA 5
Browse files Browse the repository at this point in the history
* Update get-webpack-tools.js

Added support for CRACO 7 / CRA 5 webconfig sturcture. CRA5 has only 1 module.rules "oneOf" object.

* Update src/get-webpack-tools.js

Co-authored-by: Matteo Mazzarolo <[email protected]>

* Update src/get-webpack-tools.js

Co-authored-by: Matteo Mazzarolo <[email protected]>

Co-authored-by: Matteo Mazzarolo <[email protected]>
  • Loading branch information
Snotax and mmazzarolo authored Dec 9, 2022
1 parent f247480 commit 1431875
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/get-webpack-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ module.exports = function getWebpackTools(params = {}) {
// Allow importing from external workspaces.
const workspaces = getWorkspaces({ cwd });
function enableWorkspacesResolution(webpackConfig) {
const babelLoader = webpackConfig.module.rules[1].oneOf.find((rule) =>
let targetIndex = 1;
if (webpackConfig.module.rules.length === 1) {
targetIndex = 0; // CRACO 7 / CRA 5 has only one rule
}

const babelLoader = webpackConfig.module.rules[targetIndex].oneOf.find((rule) =>
rule.loader && rule.loader.includes("babel-loader")
);
babelLoader.include = Array.isArray(babelLoader.include)
Expand Down

0 comments on commit 1431875

Please sign in to comment.