0.2.3 • Published 5 years ago

babel-plugin-version v0.2.3

Weekly downloads
380
License
MIT
Repository
-
Last release
5 years ago

babel-plugin-version

A babel plugin replace define Identifier / StringLiteral to pkg.version!

npm npm

Install

npm i --save-dev babel-plugin-version

Usage

Add it into .babelrc.

{
  "plugins": [
    "version"
  ]
}

Result

  • Input
const a = { a: __VERSION__ };

const b = a === __VERSION__;

const c = [__VERSION__];

const d =__VERSION__ = 1;

const e = "__VERSION__";
  • Output
const a = { a: "0.1.0" };

const b = a === "0.1.0";

const c = ["0.1.0"];

const d = __VERSION__ = 1;

const e = "0.1.0";

Configure

You can customize the default __VERSION__ define.

{
  "plugins": [
    ["version", {
      "define": "__PKG_VERSION__",
      "identifier": false,
      "stringLiteral": true 
     }]
  ]
}

Test

npm i

npm t

Then see the files in lib dir.

License

MIT

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.1-beta.1

5 years ago