How to use the process.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 alecortega / palettable / client / config / webpack.config.prod.js View on Github external
const publicPath = paths.servedPath;
// Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseRelativeAssetPaths = publicPath === "./";
// Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);

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

// Note: defined here because it will be used more than once.
const cssFilename = "static/css/[name].[contenthash:8].css";

// ExtractTextPlugin expects the build output to be flat.
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
// However, our output is structured with css, js and media folders.
// To have this structure working with relative paths, we have to use custom options.
const extractTextPluginOptions = shouldUseRelativeAssetPaths
  ? // Making sure that the publicPath goes back to to build folder.
    { publicPath: Array(cssFilename.split("/").length).join("../") }
  : {};

// This is the production configuration.
github pugnascotia / spring-react-boilerplate / src / main / app / config / webpack.config.prod.js View on Github external
const publicPath = paths.servedPath;
// Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseRelativeAssetPaths = publicPath === './';
// Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);

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

// Note: defined here because it will be used more than once.
const cssFilename = 'static/css/[name].[contenthash:8].css';

// ExtractTextPlugin expects the build output to be flat.
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
// However, our output is structured with css, js and media folders.
// To have this structure working with relative paths, we have to use custom options.
const extractTextPluginOptions = shouldUseRelativeAssetPaths
  ? // Making sure that the publicPath goes back to to build folder.
    { publicPath: Array(cssFilename.split('/').length).join('../') }
  : {};

// This is the production configuration.
github rocket-internet-berlin / RocketDashboard / config / webpack.config.prod.js View on Github external
// Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
const publicPath = paths.servedPath;
// Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseRelativeAssetPaths = publicPath === './';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);

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

// Note: defined here because it will be used more than once.
const cssFilename = 'static/css/[name].[contenthash:8].css';

// ExtractTextPlugin expects the build output to be flat.
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
// However, our output is structured with css, js and media folders.
// To have this structure working with relative paths, we have to use custom options.
function getExtractTextPluginOptions() {
  const options = {
    fallback: 'style-loader',
    use: [
      {
        loader: 'css-loader',
github sharmalab / Datascope / main.js View on Github external
bodyParser = require("body-parser"),
    methodOverride = require("method-override"),
    cookieParser = require("cookie-parser"),
    cookieSession = require("cookie-session");

//App modules

var dataSource = require("./modules/dataSource"),
    dataDescription = require("./modules/dataDescription"),
    interactiveFilters = require("./modules/interactiveFilters"),
    visualization = require("./modules/visualization");

var app = express();

// all environments
app.set("port", process.env.PORT || 3001);
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "jade");
//app.use(favicon());
app.use(morgan("dev"));

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())

app.use(methodOverride());
app.use(compress);
app.use(cookieParser("S3CRE7"));
app.use(cookieSession({
  name: 'session',
  keys: ['key1', 'key2']
github GilbertGobbels / GAwesomeBot / Internals / Worker.js View on Github external
/* eslint-disable callback-return */

const process = require("process");
global.logger = new (require("./Logger"))(`Shard ${Number(process.env.SHARDS)} Worker`);

require("../Modules/Utils/ObjectDefines")();

const { WorkerCommands: { MATHJS: MathJSCommands } } = require("./Constants");
const configJS = require("../Configurations/config.js");
const auth = require("../Configurations/auth.js");
const Emoji = require("../Modules/Emoji/Emoji");
const ExtensionManager = require("./Extensions");

const mathjs = require("mathjs");
const safeEval = mathjs.eval;

mathjs.import({
	import: () => { throw new Error(`Function "import" is disabled inside calculations!`); },
	createUnit: () => { throw new Error(`Function "createUnit" is disabled inside calculations!`); },
	eval: () => { throw new Error(`Function "eval" is disabled inside calculations!`); },
github rei / rei-cedar / postcss.config.js View on Github external
'postcss-simple-vars': {},
    'postcss-calc': {},
    'postcss-nested': {},
    'postcss-media-minmax': {},
    'postcss-custom-media': {},
    'postcss-pxtorem': {
      rootValue: 10,
      unitPrecision: 5,
      propList: ['*'],
      selectorBlackList: [/^html$/],
      mediaQuery: false,
      minPixelValue: 0,
    },
    'postcss-inline-svg': {
      // for correct paths during component-only css creation
      path: process.env.NODE_ENV === 'css' ? './src/components/button/styles/' : '',
    },
    ...(process.env.NODE_ENV === 'css' ? {
      'postcss-modules': {
        getJSON: () => { },
        generateScopedName: '[local]',
      },
    } : {}),
    autoprefixer: {},
    cssnano: {
      discardUnused: { fontFace: false },
    },
  },
};
github oasislabs / oasis.js / packages / client / src / workspace.ts View on Github external
get(
      workspaceCache: { [key: string]: ServiceDefinition },
      serviceName: string
    ) {
      const find = require('find');
      const fs = require('fs');
      const process = require('process');

      if (typeof window !== 'undefined') {
        throw new Error(
          '`oasis.workspace` is not (yet) available in the browser'
        );
      }

      if (!_populatedWorkspace) {
        let projectRoot = process.env.OASIS_WORKSPACE;
        if (projectRoot === undefined) {
          const path = require('path');

          projectRoot = process.cwd();
          while (!fs.existsSync(path.join(projectRoot, '.git'))) {
            const parentDir = path.dirname(projectRoot);
            if (parentDir === projectRoot) {
              projectRoot = undefined;
            }
            projectRoot = parentDir;
          }
        }

        if (projectRoot === undefined) {
          throw new Error(
            'Could not find workspace root. Perhaps set the `OASIS_WORKSPACE` env var?'
github HospitalRun / hospitalrun-frontend / script / server.js View on Github external
#!/usr/bin/env node

'use strict';

const http = require('http');
const process = require('process');
const child = require('child_process');

let couchurl = process.env.COUCHDB_URL ? process.env.COUCHDB_URL : 'http://localhost:5984';

if (typeof couchurl === undefined || couchurl === null) {
  couchurl = 'http://localhost:5984';
}

const testCouchServer = function(url) {
  return new Promise((resolve, reject) => {
    let request = http.get(url, (response) => {
      let dataChunk = '';
      if (response.statusCode !== 200) {
        reject(new Error('Access to chouchDB failed.'));
      }

      response.on('data', (data) => { dataChunk += data; });
      response.on('end', () => {
        resolve(JSON.parse(dataChunk));
github aws-samples / appsync-refarch-realtime / sam-app / get-movie / app.js View on Github external
let env = require('process').env;
let axios = require('axios');
let AWS = require('aws-sdk');
let urlParse = require('url').URL;
let appsyncUrl = process.env.ENDPOINT;
let tmdbApiKey = process.env.TMDBKEY;
let url = 'https://api.themoviedb.org/3/movie/popular?api_key='+tmdbApiKey+'&language=en-US&page=';
let response;

let endpoint = (new urlParse(appsyncUrl)).hostname.toString();
let getMovies = `query GetMovies{
  getMovies(id: 0) {
    id
    name
    poster
    date
    plot
github dinevillar / adonis-json-api-serializer / src / Service / index.js View on Github external
constructor(Config) {
        this.config = Config.get('jsonApi');
        this.JsonApiSerializer = new Serializer(this.config.globalOptions);
        this.includeStackTrace = process.env.NODE_ENV !== 'production';
        this.JSE = JsonApiSpecificationException;
        this.JsonApiException = JsonApiException;
        this.jsonApiErrors = [];
    }