How to use the webpack.EnvironmentPlugin function in webpack

To help you get started, we’ve selected a few webpack 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 neinteractiveliterature / intercode / config / webpack / environment.js View on Github external
],
  },
  resolve: {
    extensions: [
      '.js', '.jsx',
      '.sass', '.scss',
      '.css', '.png',
      '.svg', '.gif',
      '.jpeg', '.jpg'
    ],
    alias: {
      'lodash.isequal': 'lodash-es/isEqual'
    },
  },
  plugins: [
    new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(process.env))),
    // new LodashModuleReplacementPlugin({
    //   shorthands: true,
    // }),
    new CaseSensitivePathsPlugin(),
    new MiniCssExtractPlugin({
      filename: '[name]-[contenthash:8].css',
      chunkFilename: '[name]-[contenthash:8].chunk.css'
    }),
    new WebpackAssetsManifest({
      writeToDisk: true,
      publicPath: true
    }),
    // don't load all of moment's locales
    new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  ],
  node: {
github kresusapp / kresus / scripts / webpack / development.js View on Github external
var webpack = require('webpack');
const config = require('./base.js');

config.plugins.push(
    // Set process.env.NODE_ENV to development, if it's not set, and
    // replaces instances in the code.
    new webpack.EnvironmentPlugin({ 'NODE_ENV': 'development' })
);

config.devtool = 'cheap-module-eval-source-map';

module.exports = config;
github ealmansi / graphqlzero / packages / subocean-tiger-web / next.config.js View on Github external
webpack(config) {
    config.plugins.push(new webpack.EnvironmentPlugin([
      'JSON_PLACEHOLDER_URL',
      'GRAPHQL_SERVER_URL'
    ]))
    return config
  }
};
github thedevs-network / kutt / next.config.js View on Github external
webpack(config) {
    config.plugins.push(new webpack.EnvironmentPlugin(localEnv));

    return config;
  }
});
github SUI-Components / sui / packages / sui-bundler / webpack.config.lib.js View on Github external
app: MAIN_ENTRY_POINT,
        vendor: config.vendor
      }
    : MAIN_ENTRY_POINT,
  target: 'web',
  output: {
    jsonpFunction: 'suiWebpackJsonp',
    chunkFilename: '[name].[chunkhash:8].js',
    filename: 'index.js'
  },
  optimization: {
    minimizer: [minifyJs(sourceMap)]
  },
  plugins: cleanList([
    new webpack.HashedModuleIdsPlugin(),
    new webpack.EnvironmentPlugin(envVars(config.env)),
    definePlugin()
  ]),
  module: {
    rules: [babelRules]
  },
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty'
  }
}
github cozy / cozy-client-js / webpack.config.js View on Github external
exclude: /node_modules/
      }
    ]
  },
  node: {
    crypto: false
  }
}

if (NODE_TARGET === 'node') {
  config.externals = [nodeExternals()]
  config.plugins = [
    new webpack.ProvidePlugin({
      btoa: 'btoa'
    }),
    new webpack.EnvironmentPlugin(Object.keys(process.env))
  ]
} else if (production) {
  config.plugins = [
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      mangle: true,
      compress: {
        warnings: false
      }
    })
  ]
}

module.exports = config
github envato / extensions-sketch-plugin / webpack.skpm.config.js View on Github external
module.exports = function(config, isPluginCommand) {
  config.plugins.push(new webpack.EnvironmentPlugin(["ENV"]));
  config.plugins.push(
    new CopyWebpackPlugin([
      {
        from: path.resolve("./resources/icon.png"),
        to: path.resolve(pluginResourcesPath)
      }
    ])
  );
  config.module.rules.push({
    test: /\.(html)$/,
    use: [
      {
        loader: "@skpm/extract-loader"
      },
      {
        loader: "html-loader",
github Lemoncode / simplechart / next.config.js View on Github external
webpack: (config) => {
    const originalEntry = config.entry;
    config.entry = () => originalEntry()
      .then((entry) => ({
        ...entry,
        'appStyles': './content/styles/styles.scss',
      }));

    config.plugins.push(
      new webpack.EnvironmentPlugin(process.env)
    );

    return config;
  },
}));
github smooth-code / smooth.js / packages / smooth / src / config / webpack.js View on Github external
whitelist: [/\.(?!(?:jsx?|json)$).{1,5}$/i, /^smooth[/\\]/],
            }),
            'graphql/type',
            'graphql/language',
            'graphql/execution',
            'graphql/validation',
          ]
        : undefined,
    output: {
      path: path.join(config.cachePath, target, 'static'),
      filename: dev ? '[name].js' : '[name]-bundle-[chunkhash:8].js',
      publicPath: `/web/static/`,
      libraryTarget: target === 'node' ? 'commonjs2' : undefined,
    },
    plugins: [
      new webpack.EnvironmentPlugin({
        __smooth_blocks: blocksPath,
        __smooth_pages: config.pagesPath,
      }),
      new LoadablePlugin(),
      ...(target === 'node' && dev ? [new SmoothCacheHotReloader()] : []),
      ...(target === 'web' && dev
        ? [new webpack.HotModuleReplacementPlugin()]
        : []),
    ],
  }

  const webpackConfig = onCreateWebpackConfig(config)({
    stage: getStage({ target, dev }),
    webpackConfig: defaultWebpackConfig,
  })
github xing / hops / packages / build-config / configs / develop.js View on Github external
filename: getAssetPath('[name].js'),
    chunkFilename: getAssetPath('chunk-[id].js'),
    devtoolModuleFilenameTemplate: function(info) {
      return path.resolve(info.absoluteResourcePath).replace(/\\/g, '/');
    },
  },
  context: hopsConfig.appDir,
  resolve: require('../sections/resolve')('develop'),
  module: {
    rules: require('../sections/module-rules')('develop'),
  },
  plugins: [
    new ServiceWorkerPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.EnvironmentPlugin(
      Object.assign(
        {
          NODE_ENV: 'development',
        },
        hopsConfig.envVars
      )
    ),
  ],
  performance: {
    hints: false,
  },
  devtool: 'cheap-module-eval-source-map',
  watchOptions: {
    aggregateTimeout: 300,
    ignored: /node_modules/,
  },