Gulp Babel AMD转换例子

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"
}
}
上一篇:Linux 上从 MySQL 迁移到 MariaDB 的简单步骤


下一篇:QQ 微信 新浪 无法 分享 收集