Skip to content

Commit

Permalink
chore: switch from react-app-rewired to craco
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu committed Dec 6, 2023
1 parent 0d7e5f2 commit 01bdef4
Show file tree
Hide file tree
Showing 3 changed files with 760 additions and 35 deletions.
24 changes: 24 additions & 0 deletions craco.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
import { Configuration } from "webpack/types.d";

const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");

const config = {
babel: {
plugins: ["@emotion/babel-plugin"],
},
webpack: {
plugins: [new NodePolyfillPlugin()],
configure: (webpackConfig: Configuration) => {
if (!webpackConfig?.resolve?.plugins) return webpackConfig;

// Allow imports outside of src/
webpackConfig.resolve.plugins = webpackConfig.resolve.plugins.filter(
({ constructor }: InstanceType<typeof ModuleScopePlugin>) => constructor?.name !== "ModuleScopePlugin",
);
return webpackConfig;
},
},
};

export default config;
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"license": "MIT",
"private": true,
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --watchAll=false --verbose",
"start": "craco start",
"build": "craco build",
"test": "craco test --watchAll=false",
"lint": "eslint --max-warnings 0 .",
"lint:fix": "eslint --fix .",
"coverage": "yarn test --coverage",
"eject": "react-scripts eject",
"eject": "craco eject",
"fmt": "prettier --check '**/*.ts'",
"fmt:write": "prettier --write '**/*.ts'",
"prepare": "husky install",
Expand Down Expand Up @@ -38,7 +39,6 @@
"lodash.debounce": "^4.0.8",
"react": "^17.0.2",
"react-ace": "^10.1.0",
"react-app-rewired": "^2.2.1",
"react-csv-reader": "^4.0.0",
"react-dom": "^17.0.2",
"react-dropzone": "^14.2.3",
Expand All @@ -51,6 +51,7 @@
"typescript": "~5.0.4"
},
"devDependencies": {
"@craco/craco": "^7.0.0",
"@simbathesailor/use-what-changed": "^2.0.0",
"@svgr/webpack": "^8.0.1",
"@testing-library/react": "^12.1.3",
Expand All @@ -71,6 +72,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"node-polyfill-webpack-plugin": "^2.0.1",
"postcss-normalize": "^10.0.1",
"prettier": "^2.8.4",
"pretty-quick": "^3.1.3",
Expand Down
Loading

0 comments on commit 01bdef4

Please sign in to comment.