title: Environment variable with webpack on dev and production
body: <p>I am pretty new to the world of using such build tools like Webpack and its relatives, so maybe this question is a little noobish but please understand me.</p>
  
  <p>background: I am developing an client side web app (using reactjs + redux) and using webpack as my build tool and dev-server loader. Right now I have to make some lines of code only in dev environment (logging and stuff). So I saw over the net the usage of <code>webpack.DefinePlugin</code> plugin to set the <code>process.env.NODE_ENV</code> variable and the code is like this:</p>
  
  <pre><code>plugins: [
          new webpack.DefinePlugin({
              'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
          })
  ] 
  </code></pre>
  
  <p>Then if the <code>NODE_ENV</code> varibale is not set on my machine (which is not at the moment) it automatically set to development. Am I right?</p>
  
  <p>What about the production machine? do i need to set this env variable to 'production' in the <code>/etc/environment</code> file?</p>
  
  <p>Then another question is how webpack knows what is the NODE_ENV when I serve the app? is it compiled when I do the build on the production machine and set in the built bundle.js? (<code>$ webpack --progress -p</code>)</p>
  
  <p>Another question is how do I enable/disable features in production or development environment? just do an if condition statement like this: </p>
  
  <pre><code>if(process.env.NODE_ENV == 'development'){
      console.log('this is visible in development');
  }
  </code></pre>
  
  <p>And last one, if this is what webpack really does, is it transpiling this piece of code to the built bundle.js? if so, it is visible to end user right? is there something to do with that?</p>
  
  <p>Hope it's not to much, thanks a bunch!</p>