0

I was told to put the following code in my package.json to make my react/node app run faster:

  "babel": {
    "env": {
      "production": {
        "plugins": [
          "transform-react-constant-elements",
          "transform-react-inline-elements"
        ]
      }
    }
  }

Similarly I have some dependencies that are supposedly for developement:

"devDependencies": {
    "babel-cli": "^6.16.0",
    "babel-eslint": "^7.0.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-2": "^6.17.0",
    "eslint": "^3.7.1",
    "eslint-plugin-react": "^6.4.0",
    "nodemon": "^1.11.0",
    "webpack": "^1.13.2"
  },

This being my first time deploying a live site (on AWS), I was wondering how the software I'm using knows whether the app is in production mode or in developement? If this question leads you to believe I may be ignorant with regard to other things necessary to optimally deploy a site, please fill me in, thank you.

2 Answers2

0

Just set the environment variable to "production", many services you deploy on do that by default.

5ar
  • 2,069
  • 10
  • 27
  • Which environment variable? – Matt Apr 07 '17 at 02:14
  • @5ar yes can you please clarify which one – stckoverflowaccnt12 Apr 07 '17 at 03:45
  • the node environment, the syntax depends which OS you are using but it goes something like `NODE_ENV=production`, for a few examples check out [this](http://stackoverflow.com/questions/9198310/how-to-set-node-env-to-production-development-in-os-x) – 5ar Apr 07 '17 at 12:54
0
if (process.env.NODE_ENV === 'production') {
  // some code here
}
zloctb
  • 10,592
  • 8
  • 70
  • 89
  • might be worth adding some more info about what `process.env.NODE_ENV` is for those unfamiliar. – aug Jan 05 '18 at 12:51