Socket
Book a DemoInstallSign in
Socket

extended-define-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extended-define-webpack-plugin

Extended version of webpack.DefinePlugin

0.1.3
latest
Source
npmnpm
Version published
Weekly downloads
854
-31.95%
Maintainers
1
Weekly downloads
 
Created
Source

extended-define-webpack-plugin

Extended version of webpack.DefinePlugin

Installation

npm install extended-define-webpack-plugin --save-dev

Example Usage

We want to inject a configuration object and use it in our code.

// app.config.js
module.exports = {
    api_key: '1234567890ABCDEFG'
    fb_conf: {
      use_social: true,
      api_key: '123456790'
    }
};

We use the ExtendedDefinePlugin in our webpack configuration like this:

// webpack.config.js

var ExtendedDefinePlugin = require('extended-define-webpack-plugin');
var appConfig = require('./app.config.js');

module.exports = {
  // ...
  plugins: [
    /* ..., */
    new ExtendedDefinePlugin({
      APP_CONFIG: appConfig,
    })
  ]
};

In our client code we can just use it!

// main.js

// ...

var server_api_key = APP_CONFIG.api_key;

// ...

if (APP_CONFIG.fb_conf.use_social) {
  var fb_api_key = APP_CONFIG.fb_conf.api_key;
}

// ...

Output

The example above will produce this output:

// main.js

// ...

var server_api_key = ('1234567890ABCDEFG');

// ...

if ((true)) {
  var fb_api_key = ('123456790');
}

// ...

Keywords

webpack

FAQs

Package last updated on 22 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.