Skip to content

Commit c7c9a93

Browse files
Add customize-cra, config babelrc to remove console in prod
1 parent dbed187 commit c7c9a93

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"env": {
3+
"production": {
4+
"plugins": ["transform-remove-console"]
5+
}
6+
}
7+
}

config-overrides.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module.exports = function override(config, env) {
2-
//do stuff with the webpack config...
3-
console.log('config overrides: ', env);
4-
return config;
5-
};
1+
const { useBabelRc, override } = require('customize-cra');
2+
3+
module.exports = override(useBabelRc());

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@testing-library/jest-dom": "^4.2.4",
77
"@testing-library/react": "^9.3.2",
88
"@testing-library/user-event": "^7.1.2",
9+
"babel-plugin-transform-remove-console": "^6.9.4",
910
"customize-cra": "^0.9.1",
1011
"node-sass": "^4.13.0",
1112
"react": "^16.12.0",

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import logo from './logo.svg';
33
import './App.scss';
44

55
function App() {
6+
console.log("This console will be remove in Production mode");
7+
68
return (
79
<div className="App">
810
<header className="header">

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,11 @@ babel-plugin-transform-react-remove-prop-types@0.4.24:
20672067
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz#f2edaf9b4c6a5fbe5c1d678bfb531078c1555f3a"
20682068
integrity sha512-eqj0hVcJUR57/Ug2zE1Yswsw4LhuqqHhD+8v120T1cl3kjg76QwtyBrdIk4WVwK+lAhBJVYCd/v+4nc4y+8JsA==
20692069

2070+
babel-plugin-transform-remove-console@^6.9.4:
2071+
version "6.9.4"
2072+
resolved "https://registry.yarnpkg.com/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz#b980360c067384e24b357a588d807d3c83527780"
2073+
integrity sha1-uYA2DAZzhOJLNXpYjYB9PINSd4A=
2074+
20702075
babel-preset-jest@^24.9.0:
20712076
version "24.9.0"
20722077
resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.9.0.tgz#192b521e2217fb1d1f67cf73f70c336650ad3cdc"

0 commit comments

Comments
 (0)