title: process.env.NODE_ENV returns undefined in webpack 4, server-side
body: <p>in server code I have this:</p>
  
  <pre><code>import express from "express";
  const server = express();
  import path from "path";
  // const expressStaticGzip = require("express-static-gzip");
  import expressStaticGzip from "express-static-gzip";
  import webpack from "webpack";
  import webpackHotServerMiddleware from "webpack-hot-server-middleware";
  
  import configDevClient from "../../config/webpack.dev-client";
  import configDevServer from "../../config/webpack.dev-server.js";
  import configProdClient from "../../config/webpack.prod-client.js";
  import configProdServer from "../../config/webpack.prod-server.js";
  
  const isProd = process.env.NODE_ENV === "production";
  const isDev = !isProd;
  const PORT = process.env.PORT || 8000;
  let isBuilt = false;
  
  const done = () =&gt; {
    !isBuilt &amp;&amp;
      server.listen(PORT, () =&gt; {
        isBuilt = true;
        console.log(
          `Server listening on http://localhost:${PORT} in ${process.env.NODE_ENV}`
        );
      });
  };
  
  if (isDev) {
    const compiler = webpack([configDevClient, configDevServer]);
  
    const clientCompiler = compiler.compilers[0];
    const serverCompiler = compiler.compilers[1];
  
    const webpackDevMiddleware = require("webpack-dev-middleware")(
      compiler,
  
      configDevClient.devServer
    );
  
    const webpackHotMiddlware = require("webpack-hot-middleware")(
      clientCompiler,
      configDevClient.devServer
    );
  
    server.use(webpackDevMiddleware);
    server.use(webpackHotMiddlware);
    console.log("process.env.NODE_ENV",process.env.NODE_ENV);//RETURNS UNDEFINED
    server.use(webpackHotServerMiddleware(compiler));
    console.log("Middleware enabled");
    done();
  } else {
    webpack([configProdClient, configProdServer]).run((err, stats) =&gt; {
      const clientStats = stats.toJson().children[0];
      const render = require("../../build/prod-server-bundle.js").default;
      server.use(
        expressStaticGzip("dist", {
          enableBrotli: true
        })
      );
      server.use(render({ clientStats }));
      done();
    });
  }
  </code></pre>
  
  <p>I client and server config files I have this plugin enabled:</p>
  
  <pre><code>new webpack.DefinePlugin({
        "process.env": {
          NODE_ENV: JSON.stringify("development"),
          WEBPACK: true
        }
  </code></pre>
  
  <p>but this is the output</p>
  
  <pre><code>process.env.NODE_ENV undefined
  Server listening on http://localhost:8000 in undefined
  </code></pre>
  
  <p>in client side it is working BUT express side process.env.NODE_ENV returns undefined</p>