"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.configEnvVariables = configEnvVariables;

var _webpack = require("webpack");

var _modeUtils = require("../common/modeUtils");

function getDevEnvs(NODE_ENV) {
  return {
    __CLIENT__: true,
    __TEST__: false,
    __SERVER__: false,
    __DEVELOPMENT__: true,
    __LOCAL_PRODUCTION__: false,
    __DEVTOOLS__: true,
    __DOCS__: false,
    'process.env': {
      NODE_ENV
    }
  };
}

function getProdEnvs(isDevelopment) {
  return {
    __CLIENT__: true,
    __TEST__: false,
    __SERVER__: false,
    __DEVELOPMENT__: false,
    __LOCAL_PRODUCTION__: isDevelopment,
    __DOCS__: false,
    'process.env': {
      NODE_ENV: JSON.stringify('production')
    }
  };
}

function configEnvVariables(options) {
  // const mode = getWebpackMode(options);
  const {
    disableReactDevWarning,
    mode,
    devLikeHash
  } = options;
  const isDevelopment = devLikeHash;
  const NODE_ENV = disableReactDevWarning ? JSON.stringify('production') : JSON.stringify('development');
  return new _webpack.DefinePlugin((0, _modeUtils.isDevelopmentMode)(mode) ? getDevEnvs(NODE_ENV) : getProdEnvs(isDevelopment));
}