码迷,mamicode.com
首页 > 其他好文 > 详细

Gulp Babel AMD转换例子

时间:2016-04-28 11:52:38      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

1.gulpfile.js

var gulp = require(‘gulp‘);

const babel = require(‘gulp-babel‘);

gulp.task(‘default‘, () => {
    return gulp.src(‘src/**/*.js‘)
        .pipe(babel({
            presets: [‘es2015‘],
      plugins:[‘babel-plugin-transform-es2015-modules-amd‘]
        }))
        .pipe(gulp.dest(‘dist‘));
});

备注:

a. babel  -m选项不起,要使用transform plugins

b. 使用scripts 调用非global安装的Gulp

{
  "name": "es6",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "babel": "babel -d lib/ src/",
    "gulp": "./node_modules/.bin/gulp"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-cli": "^6.7.7",
    "babel-core": "^6.7.7",
    "babel-polyfill": "^6.7.4",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-stage-0": "^6.5.0",
    "gulp": "^3.9.1",
    "gulp-babel": "^6.1.2"
  },
  "dependencies": {
    "amdefine": "^1.0.0",
    "requirejs-babel": "0.0.9"
  }
}

 

Gulp Babel AMD转换例子

标签:

原文地址:http://www.cnblogs.com/guangfengli/p/5441899.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!