An open API service indexing awesome lists of open source software.

https://github.com/expressenab/babel-plugin-vanilla-shake

Vanilla conditional compile babel plugin
https://github.com/expressenab/babel-plugin-vanilla-shake

babel-plugin conditional

Last synced: 4 months ago
JSON representation

Vanilla conditional compile babel plugin

Awesome Lists containing this project

README

          

vanilla-shake
=============
[![Build status](https://github.com/ExpressenAB/babel-plugin-vanilla-shake/actions/workflows/build.yaml/badge.svg?event=push)](https://github.com/ExpressenAB/babel-plugin-vanilla-shake/actions/workflows/build.yaml)

vanilla conditional compile plugin for babel.

consider this:
```js
const foo = 1;
const bar = 2;
if (SHOULD_KEEP) {
console.log(foo);
} else if (SHOULD_KEEP_2) {
console.log(bar);
} else {
console.log("hej")
}
```

configure the plugin like this:

```js
{
plugins: [["vanilla-shake", {
defined: {
SHOULD_KEEP: false,
SHOULD_KEEP_2: true
}
}]]
}
```

after code is transpiled with the configured plugin:
```js
const foo = 1;
const bar = 2;

console.log(bar);
```