Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/herrmanno/babel-plugin-conditional-compilation
C/C++ style conditional compilation for Babel
https://github.com/herrmanno/babel-plugin-conditional-compilation
Last synced: 11 days ago
JSON representation
C/C++ style conditional compilation for Babel
- Host: GitHub
- URL: https://github.com/herrmanno/babel-plugin-conditional-compilation
- Owner: herrmanno
- Created: 2016-02-10T12:46:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-02-10T14:47:46.000Z (over 8 years ago)
- Last Synced: 2024-10-11T07:13:34.620Z (27 days ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 19
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/herrmanno/babel-plugin-conditional-compilation.svg?branch=master)](https://travis-ci.org/herrmanno/babel-plugin-conditional-compilation)
# babel-plugin-conditional-compilation
c/c++ style conditional compilation
## Example
**In**
.babelrc
```json
"plugins": [
["conditional-compilation", {
"DEBUG": 2
}]
]
```somfile.js
```js
let DEBUG;
"#if DEBUG > 1";
DEBUG = 1;
"#endif";
```**Out**
somfile.js
```js
let DEBUG;DEBUG = 1;
```For *complete* examples look at [test directory](test/fixtures).
## Installation
```sh
$ npm install babel-plugin-conditional-compilation
```## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```javascript
{
"plugins": ["conditional-compilation", {/* compile-time constants */}]
}
```### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["conditional-compilation", {/* compile-time constants*/}]
});
```