How to use the process.env.NODE_ENV function in process

To help you get started, we’ve selected a few process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zouhir / jarvis / lib / server / index.js View on Github external
apply(compiler) {
    const { name, version, author: makers } = pkg;
    const normalizedAuthor = parseAuthor(makers);

    this.reports.project = { name, version, makers: normalizedAuthor };

    // check if the current build is production, via defined plugin
    const definePlugin = compiler.options.plugins.find(fn => fn.constructor.name === "DefinePlugin");

    if (definePlugin) {
      const pluginNodeEnv = definePlugin["definitions"]["process.env.NODE_ENV"];
      this.env.production = pluginNodeEnv === "production";
    }

    let jarvis;
    let isDev = !this.env.production;
    let { port, host } = this.options;

    if (!this.env.running) {
      jarvis = this.server = server.init(compiler, isDev);
      jarvis.http.listen(port, host, _ => {
        console.log(`[JARVIS] Starting dashboard on: http://${host}:${port}`);
        this.env.running = true;
        // if a new client is connected push current bundle info
        jarvis.io.on("connection", socket => {
          socket.emit("project", this.reports.project);
          socket.emit("progress", this.reports.progress);
github ghettovoice / vuelayers / build / rollup.js View on Github external
// if (ol[id] != null) {
        //   return ol[id]
        // }
      }
      options.input.external = (id, parent, resolved) => {
        if (['vue'].includes(id)) return true

        // if (!resolved && /^ol\/.+/.test(id)) {
        //   ol[id] = id.replace(/\//g, '.')
        //   return true
        // }

        return false
      }
      options.replaces['process.env.NODE_ENV'] = `'${env}'`
      options.replaces['process.env.VUELAYERS_DEBUG'] = JSON.stringify(process.env.NODE_ENV !== 'production')
      // options.minify = true
      // process.env.BABEL_ENV = 'es5-production'
      // options.defines.IS_STANDALONE = true
      break
    case 'cjs':
      options.input.external = external
      options.patterns = patterns
      // process.env.BABEL_ENV = 'es5-production'
      break
    case 'es':
      options.input.external = external
      options.patterns = patterns
      // options.outputPath = path.join(options.outputPath, '_esm')
      // options.cssName = undefined
      break
github zouyaoji / vue-cesium / build / rollup.js View on Github external
const patterns = [
    [
      // components/**/* -> **/* replacement
      {
        test: /'(\.{1,2})\/components\/([^']*)'/gi,
        replace: (m1, m2, m3) => `'${m2}/${m3}'`
      },
      // mixins/utils/exts path inside components replacement
      {
        include: ['src/components/**/*'],
        test: /'(?:\.{2}\/){2,3}((?:mixins|utils|exts)[^']*)'/gi,
        replace: (m1, m2) => (m1.split('../').length === 3 ? `'../${m2}'` : `'../../${m2}'`)
      }
    ]
  ]
  options.replaces['process.env.NODE_ENV'] = `'${env}'`
  options.replaces['process.env.VUECESIUM_DEBUG'] = JSON.stringify(process.env.NODE_ENV !== 'production')
  switch (format) {
    case 'umd':
      options.jsName += '.' + format
      options.cssName = undefined
      // const ol = {}
      options.output.globals = (id) => {
        if (id === 'vue') return 'Vue'
        // if (ol[id] != null) {
        //   return ol[id]
        // }
      }

      options.input.external = (id, parent, resolved) => {
        if (['vue'].includes(id)) return true
github IngloriousCoderz / react-property-grid / config / webpack.config.prod.js View on Github external
var path = require('path');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var url = require('url');
var paths = require('./paths');
var env = require('./env');

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
if (env['process.env.NODE_ENV'] !== '"production"') {
  throw new Error('Production builds must have NODE_ENV=production.');
}

// We use "homepage" field to infer "public path" at which the app is served.
// Webpack needs to know it to put the right 
github mariomka / vue-datetime / build / build.js View on Github external
css (styles, stylesNodes) {
          // Only generate the styles once
          if (env['process.env.NODE_ENV'] === '"production"') {
            Promise.all(
              stylesNodes.map(processStyle)
            ).then(css => {
              const result = css.map(c => c.css).join('')
              // write the css for every component
              // TODO add it back if we extract all components to individual js
              // files too
              // css.forEach(writeCss)
              write(`dist/${name}.css`, result)
              write(`dist/${name}.min.css`, new CleanCSS().minify(result).styles)
            }).catch(logError)
          }
        }
      }),
github GoogleChrome / workbox / gulp-tasks / utils / rollup-helper.js View on Github external
debug: false,
          },
        },
      };
      plugins.push(
          terserPlugin(terserOptions),
      );
    }

    // This is what the build should be
    const replaceOptions = {
      'WORKBOX_CDN_ROOT_URL': getVersionsCDNUrl(),
    };

    if (buildType) {
      replaceOptions['process.env.NODE_ENV'] = JSON.stringify(buildType);
    }

    // Replace allows us to input NODE_ENV and strip code accordingly
    plugins.push(replace(replaceOptions));

    return plugins;
  },
};
github zeromake / zreact / scripts / rollup.base.config.js View on Github external
const rollupTypescript = require('rollup-typescript');
const { terser } = require('rollup-plugin-terser')
// const { uglify } = require('rollup-plugin-uglify');
// const { minify } = require('uglify-es');
const replace = require('rollup-plugin-re');
const license = require("rollup-plugin-license");
const filesize = require("rollup-plugin-filesize");
const pkg = require('../package.json');

const isProduction = process.env.NODE_ENV === 'production';

const rollupTypescriptPlugin = rollupTypescript({typescript: require('typescript')});
const replaceOptions = {};
if(isProduction) {
    replaceOptions['process.env.NODE_ENV'] = JSON.stringify(process.env.NODE_ENV)
}
const replacePlugin = replace({
    replaces: replaceOptions
});

const licensePlugin = license({
    banner: `zreact JavaScript Library v${pkg.version}
    https://github.com/zeromake/zreact
    Copyright zeromake 
    license MIT
    Date ${JSON.stringify(new Date())}
    `
});

const filesizePlugin = filesize()
github amovah / speedster / src / electron / index.js View on Github external
import '@babel/polyfill';
import {
  app,
  BrowserWindow,
  Menu,
  dialog,
} from 'electron';
import { resolve } from 'path';
import { env } from 'process';
import shutdown from 'Root/helpers/shutdown';
import init from './init';
import tray from './tray';

if (env.NODE_ENV === 'development') {
  require('electron-reload')(resolve(__dirname, '..'), { // eslint-disable-line
    electron: resolve(__dirname, '..', 'node_modules', 'electron', 'dist', 'electron'),
  });
}

let win;
function createWindow() {
  win = new BrowserWindow({
    minWidth: 1000,
    minHeight: 600,
    icon: resolve(__dirname, '../icons/512x512.png'),
    title: 'Speedster',
    show: false,
    webPreferences: {
      nodeIntegration: true,
    },
github supercomments / supercomments / config / webpack.config.prod.js View on Github external
var path = require('path');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var url = require('url');
var paths = require('./paths');
var env = require('./env');

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
if (env['process.env.NODE_ENV'] !== '"production"') {
  throw new Error('Production builds must have NODE_ENV=production.');
}

// We use "homepage" field to infer "public path" at which the app is served.
// Webpack needs to know it to put the right