Score
0
Watch 1 Star 0 Fork 0

小为 / babel-plugin-versionJavaScript

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
:label: babel plugin replace define identifier `__VERSION__` to pkg.version! spread retract

Clone or download
hustcc authored ignore
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

babel-plugin-version

A babel plugin replace define Identifier to pkg.version!

npm

Install

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

Usage

Add it into .babelrc.

{
  "plugins": [
    "version"
  ]
}

Result

  • In
const a = { a: __VERSION__ };

const b = a === __VERSION__;

const c = [__VERSION__];

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

const b = a === "0.1.0";

const c = ["0.1.0"];

const d = __VERSION__ = 1;

Configure

You can customize the default __VERSION__ define.

{
  "plugins": [
    ["version", { "define": "__PKG_VERSION__" }]
  ]
}

Test

npm i

npm t

Then see the files in lib dir.

License

MIT

Comments ( 0 )

Sign in for post a comment

JavaScript
1
https://gitee.com/hustcc/babel-plugin-version.git
git@gitee.com:hustcc/babel-plugin-version.git
hustcc
babel-plugin-version
babel-plugin-version
master

Help Search