Skip to content

Commit

Permalink
Use CRACO to workaround CRA #11770
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Jun 22, 2023
1 parent a7ca6a8 commit 8038e19
Show file tree
Hide file tree
Showing 3 changed files with 5,391 additions and 6,383 deletions.
28 changes: 28 additions & 0 deletions frontend/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
// Fix CRA #11770
const rules = webpackConfig.module.rules;
for (const rule of rules) {
if (Object.hasOwn(rule, 'oneOf')) {
rule.oneOf.filter((currentValue, index, arr) => {
const toRemove =
currentValue.test instanceof RegExp && currentValue.test.test('something.svg');
if (toRemove) {
arr.splice(index, 1);
}
return toRemove;
});
rule.oneOf.push({
test: /\.svg$/i,
issuer: {
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
},
type: 'asset',
});
}
}
return webpackConfig;
},
},
};
9 changes: 5 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"react-placeholder": "^4.1.0",
"react-redux": "^7.2.4",
"react-router-dom": "^6.10.0",
"react-scripts": "^4.0.3",
"react-select": "^5.7.0",
"react-tooltip": "^4.2.21",
"reactjs-popup": "^2.0.5",
Expand Down Expand Up @@ -84,11 +83,11 @@
"patch-id": "bash -c \"cp patch/imagery.min.json public/static/id/data\"",
"patch-rapid": "bash -c \"cp patch/rapid-imagery.min.json public/static/rapid/data/imagery.min.json\"",
"preparation": "bash -c \"if (test -a ../tasking-manager.env); then grep -hs ^ ../tasking-manager.env .env.expand > .env; else cp .env.expand .env; fi\"",
"start": "npm run preparation && npm run copy-static && npm run patch-id && npm run patch-rapid && react-scripts start",
"build": "npm run preparation && npm run update-static && npm run patch-id && npm run patch-rapid && react-scripts build",
"start": "npm run preparation && npm run copy-static && npm run patch-id && npm run patch-rapid && craco start",
"build": "npm run preparation && npm run update-static && npm run patch-id && npm run patch-rapid && craco build --stats",
"prettier": "prettier --write 'src/**/*.js'",
"lint": "eslint src",
"test": "npm run lint && react-scripts test --env=jsdom",
"test": "npm run lint && craco test --env=jsdom",
"coverage": "npm run test -- --coverage --watchAll=false",
"analyze": "source-map-explorer 'build/static/js/*.js'"
},
Expand All @@ -108,6 +107,7 @@
]
},
"devDependencies": {
"@craco/craco": "^7.1.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
Expand All @@ -116,6 +116,7 @@
"jest-canvas-mock": "^2.3.1",
"msw": "0.49.2",
"prettier": "^2.8.1",
"react-scripts": "^5.0.1",
"react-select-event": "^5.5.1",
"react-test-renderer": "^17.0.2",
"source-map-explorer": "^2.5.3"
Expand Down
Loading

0 comments on commit 8038e19

Please sign in to comment.