define-env-plugin

0.1.5 • Public • Published

define-env-plugin

Enable client code to get node variables

Installation

yarn add define-env-plugin -D

Usage

// webpack.config.js
 
const DefineEnvPlugin = require('define-env-plugin');
 
module.exports = {
  plugins: [
    // 
    new DefineEnvPlugin(['APP_VERSION', 'AUTHOR'])
  ]
};

In client code use it

// main.js
// process.env can get the fields in the scripts of package.js
 
console.log(process.env);

Options

NODE_ENV and SERVICE_URL are built in by default, You can pass in other fields

  DefineEnvPlugin(['APP_VERSION', 'AUTHOR'])

Available options are:

NODE_ENV (string): environment for browser.

SERVICE_URL (string): http url for api.

SOCKET_URL (string): websocket url for api.

Package Sidebar

Install

npm i define-env-plugin

Weekly Downloads

17

Version

0.1.5

License

MIT

Unpacked Size

3.49 kB

Total Files

5

Last publish

Collaborators

  • bearcookie