Skip to content

Commit 006e85b

Browse files
author
Manuel Gellfart
authored
chore: switch from react-app-rewired to craco (#572)
* chore: switch from react-app-rewired to craco * fix: browser list for BigInt compatibility * fix: prod build and add serve script * chore: increase version number
1 parent 0d7e5f2 commit 006e85b

File tree

4 files changed

+766
-42
lines changed

4 files changed

+766
-42
lines changed

craco.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
2+
import { Configuration } from "webpack/types.d";
3+
4+
const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
5+
6+
const config = {
7+
babel: {
8+
plugins: ["@emotion/babel-plugin"],
9+
},
10+
webpack: {
11+
plugins: [new NodePolyfillPlugin()],
12+
configure: (webpackConfig: Configuration) => {
13+
if (!webpackConfig?.resolve?.plugins) return webpackConfig;
14+
15+
// Allow imports outside of src/
16+
webpackConfig.resolve.plugins = webpackConfig.resolve.plugins.filter(
17+
({ constructor }: InstanceType<typeof ModuleScopePlugin>) => constructor?.name !== "ModuleScopePlugin",
18+
);
19+
return webpackConfig;
20+
},
21+
},
22+
};
23+
24+
export default config;

package.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
22
"name": "safe-airdrop",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"license": "MIT",
55
"private": true,
66
"scripts": {
7-
"start": "react-app-rewired start",
8-
"build": "react-app-rewired build",
9-
"test": "react-app-rewired test --watchAll=false --verbose",
7+
"start": "craco start",
8+
"build": "craco build",
9+
"test": "craco test --watchAll=false",
1010
"lint": "eslint --max-warnings 0 .",
11+
"lint:fix": "eslint --fix .",
1112
"coverage": "yarn test --coverage",
12-
"eject": "react-scripts eject",
13+
"eject": "craco eject",
1314
"fmt": "prettier --check '**/*.ts'",
1415
"fmt:write": "prettier --write '**/*.ts'",
1516
"prepare": "husky install",
1617
"generate-types": "typechain --target=ethers-v5 --out-dir src/contracts './node_modules/@openzeppelin/contracts/build/contracts/ERC20.json' './customabis/ERC721.json' './node_modules/@openzeppelin/contracts/build/contracts/ERC1155.json' './node_modules/@openzeppelin/contracts/build/contracts/ERC165.json'",
17-
"postinstall": "yarn generate-types"
18+
"postinstall": "yarn generate-types",
19+
"serve": "npx -y serve build -p 3001"
1820
},
1921
"dependencies": {
2022
"@emotion/cache": "^11.10.1",
@@ -38,7 +40,6 @@
3840
"lodash.debounce": "^4.0.8",
3941
"react": "^17.0.2",
4042
"react-ace": "^10.1.0",
41-
"react-app-rewired": "^2.2.1",
4243
"react-csv-reader": "^4.0.0",
4344
"react-dom": "^17.0.2",
4445
"react-dropzone": "^14.2.3",
@@ -51,6 +52,7 @@
5152
"typescript": "~5.0.4"
5253
},
5354
"devDependencies": {
55+
"@craco/craco": "^7.0.0",
5456
"@simbathesailor/use-what-changed": "^2.0.0",
5557
"@svgr/webpack": "^8.0.1",
5658
"@testing-library/react": "^12.1.3",
@@ -71,6 +73,7 @@
7173
"eslint-plugin-react": "^7.32.2",
7274
"eslint-plugin-react-hooks": "^4.6.0",
7375
"husky": "^8.0.3",
76+
"node-polyfill-webpack-plugin": "^2.0.1",
7477
"postcss-normalize": "^10.0.1",
7578
"prettier": "^2.8.4",
7679
"pretty-quick": "^3.1.3",
@@ -80,6 +83,8 @@
8083
"browserslist": {
8184
"production": [
8285
">0.2%",
86+
"not ie <= 99",
87+
"not android <= 4.4.4",
8388
"not dead",
8489
"not op_mini all"
8590
],

src/App.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ const App: React.FC = () => {
125125
onClick={submitTx}
126126
disabled={parsing || transfers.length + collectibleTransfers.length === 0}
127127
>
128-
{parsing && (
129-
<>
130-
<CircularProgress size={24} color="primary" />
131-
</>
132-
)}
128+
{parsing && <CircularProgress size={24} color="primary" />}
133129
{messages.length === 0 ? "Submit" : "Submit with errors"}
134130
</Button>
135131
<MessageSnackbar />

0 commit comments

Comments
 (0)