项目作者: babel

项目描述 :
A Metalsmith plugin to compile JavaScript with Babel
高级语言: JavaScript
项目地址: git://github.com/babel/metalsmith-babel.git
创建时间: 2015-01-13T21:12:00Z
项目社区:https://github.com/babel/metalsmith-babel

开源协议:ISC License

下载


metalsmith-babel

npm version
Build Status
Coverage Status

Babel plugin for Metalsmith

Installation

Use npm:

  1. npm install metalsmith-babel

And ensure the requisite Babel plugins are installed.

Usage

CLI

Add the metalsmith-babel field to your metalsmith.json.

  1. {
  2. "plugins": {
  3. "metalsmith-babel": {
  4. "presets": ["@babel/preset-env"]
  5. }
  6. }
  7. }

API

  1. const Metalsmith = require('metalsmith');
  2. const babel = require('metalsmith-babel');
  3. const babelOptions = {
  4. presets: ['env']
  5. };
  6. new Metalsmith('./source')
  7. .use(babel(babelOptions))
  8. .build((err, files) => {
  9. if (err) {
  10. throw err;
  11. }
  12. console.log('Completed.');
  13. });

Options

All @babel/core options are available except for filename and filenameRelative that will be automatically set.

License

ISC License © 2017 - 2018 Shinnosuke Watanabe