Skip to content
This repository has been archived by the owner. It is now read-only.
Builds a babel configuration for rollup with specific targets from babel-preset-env.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.eslintrc.json
.gitignore
CHANGELOG.md
LICENSE
README.md
index.js
package.json
yarn.lock

README.md

babelrc-targeted-rollup

Builds a babel configuration for rollup with specific targets from babel-preset-env.

Installation

yarn add babelrc-targeted-rollup --dev

Usage

Create a .babelrc containing the env preset.

{
    "presets": [
        ["env", {
            "targets": {
                "node"     : 6,
                "browsers" : "Last 2 versions" 
            }
        }]
    ]
}

Then, in your rollup.config.js:

import babelrc from 'babelrc-targeted-rollup';
import babel   from 'rollup-plugin-babel';

const baseOptions = {
    input    : 'src/my-package.js',
    external : ['lodash'],
    globals  : {
        'lodash': '_'
    }
};

const targets = [
    {
        output: {
            file   : 'dist/my-package.js',
            format : 'umd',
            name   : 'MyPackage'
        },
        plugins: [
            babel(babelrc('browsers'))
        ]
    },
    {
        output: {
            file   : 'dist/my-package.es.js',
            format : 'es'
        },
        plugins : [
            babel(babelrc('node'))
        ]
    }
];
export default targets.map(targetOptions => (
    Object.assign({}, baseOptions, targetOptions)
));

Options

You can pass the same options as for babelrc-rollup plus:

targets (default: [])

The babel-preset-env targets you want to have inside the returned babel configuration.

You can’t perform that action at this time.