Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/felix-kaestner/babel-plugin-transform-strip-block

Strip blocks of code marked by special comment tags.
https://github.com/felix-kaestner/babel-plugin-transform-strip-block

Last synced: about 5 hours ago
JSON representation

Strip blocks of code marked by special comment tags.

Awesome Lists containing this project

README

        

# babel-plugin-transform-strip-block

> Strip blocks of code marked by special comment tags.

Using npm:

```sh
npm install --save-dev babel-plugin-transform-strip-block
```

or using yarn:

```sh
yarn add babel-plugin-transform-strip-block --dev
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
"plugins": [
[ "babel-plugin-transform-strip-block", { "requireDirective": true, "identifiers": [{ "start": "block:start", "end": "block:end" }] }]
]
}
```

### Via Webpack

**.webpack.config.js**

```javascript
...
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
['babel-plugin-transform-strip-block', { requireDirective: true, identifiers: [{ start: 'block:start', end: 'block:end' }] }]
]
}
}
}
]
...
```

### Example

In:
```javascript
// @strip-block

const foo = {
/* block:start */
bar: 'baz',
/* block:end */
}
```

Out:
```javascript
const foo = {}
```