babel-plugin-transform-strip-block

0.0.5 • Public • Published

babel-plugin-transform-strip-block

Strip blocks of code marked by special comment tags.

Using npm:

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

or using yarn:

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

Usage

Via .babelrc (Recommended)

.babelrc

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

Via Webpack

.webpack.config.js

  ...
  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:

// @strip-block

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

Out:

const foo = {}

/babel-plugin-transform-strip-block/

    Package Sidebar

    Install

    npm i babel-plugin-transform-strip-block

    Weekly Downloads

    1,424

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    30 kB

    Total Files

    12

    Last publish

    Collaborators

    • felix-kaestner