From c54f8d95794acda70d4471807e85e7750281ae5a Mon Sep 17 00:00:00 2001 From: Matt DelSordo Date: Sun, 8 Oct 2023 21:03:27 -0400 Subject: [PATCH] disable react and redux dev tools extensions in production --- .vscode/settings.json | 5 ++++- frontend/front/.eslintignore | 1 + frontend/front/.prettierignore | 3 ++- frontend/front/package.json | 2 ++ frontend/front/src/index.js | 5 +++++ frontend/front/src/redux/store.js | 4 +--- frontend/front/yarn.lock | 5 +++++ 7 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 frontend/front/.eslintignore diff --git a/.vscode/settings.json b/.vscode/settings.json index 9bf4d12b..17eaad5c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true + "editor.formatOnSave": true, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/frontend/front/.eslintignore b/frontend/front/.eslintignore new file mode 100644 index 00000000..d1638636 --- /dev/null +++ b/frontend/front/.eslintignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/frontend/front/.prettierignore b/frontend/front/.prettierignore index 600d2d33..474e379d 100644 --- a/frontend/front/.prettierignore +++ b/frontend/front/.prettierignore @@ -1 +1,2 @@ -.vscode \ No newline at end of file +.vscode +build/ \ No newline at end of file diff --git a/frontend/front/package.json b/frontend/front/package.json index 79266cbf..81de8821 100644 --- a/frontend/front/package.json +++ b/frontend/front/package.json @@ -5,6 +5,7 @@ "dependencies": { "@emotion/react": "^11.10.0", "@emotion/styled": "^11.10.0", + "@fvilers/disable-react-devtools": "^1.3.0", "@mui/icons-material": "^5.8.4", "@mui/lab": "^5.0.0-alpha.103", "@mui/material": "^5.10.9", @@ -35,6 +36,7 @@ "scripts": { "start": "PORT=3001 react-scripts start", "build": "react-scripts build", + "serve": "npx serve build -l 3001", "test": "react-scripts test", "test-style": "run-s lint prettier", "eject": "react-scripts eject", diff --git a/frontend/front/src/index.js b/frontend/front/src/index.js index 7fefeb41..896546c0 100644 --- a/frontend/front/src/index.js +++ b/frontend/front/src/index.js @@ -5,6 +5,11 @@ import App from "./App"; import reportWebVitals from "./reportWebVitals"; import { store } from "./redux/store"; import { Provider } from "react-redux"; +import { disableReactDevTools } from "@fvilers/disable-react-devtools"; + +if (process.env.NODE_ENV === "production") { + disableReactDevTools(); +} const root = ReactDOM.createRoot(document.getElementById("root")); root.render( diff --git a/frontend/front/src/redux/store.js b/frontend/front/src/redux/store.js index b00f12e6..f8d9c526 100644 --- a/frontend/front/src/redux/store.js +++ b/frontend/front/src/redux/store.js @@ -20,10 +20,8 @@ export const createStore = (options) => // adding the api middleware enables caching, invalidation, polling and other features of `rtk-query` middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(apiSlice.middleware), + devTools: process.env.NODE_ENV !== "production", ...options, }); -// Assign the Redux store to a global property 'window.store' -window.store = createStore(); - export const store = createStore(); diff --git a/frontend/front/yarn.lock b/frontend/front/yarn.lock index f26219ca..9b6f2599 100644 --- a/frontend/front/yarn.lock +++ b/frontend/front/yarn.lock @@ -1428,6 +1428,11 @@ version "1.5.0" resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.5.0.tgz#5c05c60d5ae2d05101c3021c1a2a350ddc027f8c" integrity sha512-kK1h4m36DQ0UHGj5Ah4db7R0rHemTqqO0QLvUqi1/mUUp3LuAWbWxdxSIf/XsnH9VS6rRVPLJCncjRzUvyCLXg== +"@fvilers/disable-react-devtools@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@fvilers/disable-react-devtools/-/disable-react-devtools-1.3.0.tgz#d4f9cb23e955351765788cba363f87d88febc843" + integrity sha512-LbASP6voPkKS5b6OlQhupEDtMeoAakamauqLEFHatkQUTmblNY5nPK7/eSqKBXxExT6uypVPczpTsJjJIrhpOQ== + dependencies: "@floating-ui/utils" "^0.1.3"