How to use loose-envify - 3 common examples

To help you get started, we’ve selected a few loose-envify 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 u-wave / web / tasks / browserify.js View on Github external
});

  b.transform(yamlify);

  // Babelify transforms the üWave source code, which is written in JavaScript
  // of the future and JSX, to JavaScript of today.
  b.transform(babelify);

  // Envify replaces `process.env.*` occurrences with constant values. This is
  // mostly used to disable development tools for deployed code, because those
  // tools can take up a lot of space otherwise.
  // This doesn't actually _remove_ the unnecessary code yet, it just turns it
  // into code like:
  //     if ("production" === "development") { logDeveloperInfo(); }
  // …which will be removed by uglify.js later down the line.
  b.transform(envify({
    _: 'purge',
    NODE_ENV: process.env.NODE_ENV
  }), { global: true });

  if (minify) {
    b.transform(uglifyify, {
      global: true,
      mangle: false
    });
    // Browserify assigns numbers to all modules, but normally uses the full
    // module names in the compiled source. That's perfectly fine, but we can
    // shave off a bunch of bytes if it'd just use the assigned numbers instead,
    // because they are much shorter :)
    // The bundle-collapser plugin replaces the full module names with their
    // assigned numbers!
    b.plugin(collapse);
github WebMemex / webmemex-extension / gulpfile.babel.js View on Github external
const { dir, name } = path.parse(filePath)
    const entries = [path.join('src', filePath)]
    const destination = path.join('extension', dir)
    const output = `${name}.js` // ignore original filename extension, to replace jsx with js.

    // Hard-code the inclusion of any css file with the same name as the script.
    // We append any css-modules imported from the script to this css file.
    const cssInputPath = path.join('src', dir, `${name}.css`)
    const cssOutput = `${name}.css`

    let b = watch
        ? watchify(browserify({...watchify.args, ...browserifySettings, entries}))
            .on('update', bundle)
        : browserify({...browserifySettings, entries})
    b.transform(babelify)
    b.transform(envify({
        NODE_ENV: production ? 'production' : 'development',
    }), {global: true})

    b.plugin(cssModulesify, {
        global: true, // for importing css modules from e.g. react-datepicker.
        rootDir: path.join('src', dir),
        // output: path.join(destination, cssOutput), // We read the stream instead (see below)
        postcssBefore: [
            cssnext,
        ],
    })
    b.on('css stream', stream => {
        // Append the css-modules output to the script's eponymous plain css file (if any).
        // TODO resolve & copy @import and url()s
        stream
            .pipe(source('css-modules-output.css')) // pretend the streamed data had this filename.
github WorldBrain / Memex / gulpfile.babel.js View on Github external
function createBundle(
    { entries, output, destination, cssOutput },
    { watch = false, production = false },
) {
    const b = watch
        ? watchify(
              browserify({ ...watchify.args, ...browserifySettings, entries }),
          ).on('update', bundle)
        : browserify({ ...browserifySettings, entries })
    b.plugin(tsify)
    b.transform(babelify, { extensions: ['.js', '.jsx', '.ts', '.tsx'] })
    b.transform(
        envify({
            NODE_ENV: production ? 'production' : 'development',
            PIWIK_HOST: production
                ? 'https://analytics.worldbrain.io'
                : 'http://localhost:1234',
            PIWIK_SITE_ID: '1',
            SENTRY_DSN: production
                ? 'https://205014a0f65e4160a29db2935250b47c@sentry.io/305612'
                : undefined,
        }),
        { global: true },
    )

    if (cssOutput) {
        b.plugin(cssModulesify, {
            global: true,
            output: path.join(destination, cssOutput),

loose-envify

Fast (and loose) selective `process.env` replacer using js-tokens instead of an AST

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular loose-envify functions