🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

babel-plugin-define-variables

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

babel-plugin-define-variables

a babel define vars that like webpack.DefinePlugin

Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
90
69.81%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-define-variables

a babel plugin that like webpack.DefinePlugin

installtion

  npm install --save-dev babel-plugin-define-variables
  // or 
  yarn add -D babel-plugin-define-variables

config

// babel.config.js
module.exports = {
  presets: [
    ...
  ],
  plugins: [
    [
      'babel-plugin-define-variables',
      {
        defines: {
          'process.env.BUILD_ENV': process.env.BUILD_ENV,
          'process.env.NODE_ENV': process.env.NODE_ENV,
        }
      }
    ],
   ...
  ]
};

built-in define

  • __filename

    the filename of code file than relative of package.json path that current project.

  • __dirname

    the dirname of code file than relative of package.json path that current project.

  • __now

    the time that build moment. format: 'yyyy-MM-dd hh:mm:ss'

  • __timestamp

    the timestamp that build moment.

  • __packagename

    the package name of this project.

  • __packageversion

    the package version of this project. you can also use like this:

    __packageversion('react');
    

    that you will get version of react;

Keywords

babel

FAQs

Package last updated on 02 Dec 2020

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