framework/extensions/mentions/js/Gulpfile.js
2015-05-14 22:01:03 +09:30

47 lines
1.3 KiB
JavaScript

var gulp = require('gulp');
var livereload = require('gulp-livereload');
var concat = require('gulp-concat');
var argv = require('yargs').argv;
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var babel = require('gulp-babel');
var cached = require('gulp-cached');
var remember = require('gulp-remember');
var merge = require('merge-stream');
var streamqueue = require('streamqueue');
var staticFiles = [
'bootstrap.js',
'bower_components/textarea-caret-position/index.js'
];
var moduleFiles = [
'src/**/*.js'
];
var modulePrefix = 'mentions';
gulp.task('default', function() {
return streamqueue({objectMode: true},
gulp.src(moduleFiles)
.pipe(cached('scripts'))
.pipe(babel({ modules: 'amd', moduleIds: true, moduleRoot: modulePrefix }))
.pipe(remember('scripts')),
gulp.src(staticFiles)
.pipe(babel())
)
.pipe(concat('extension.js'))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('dist'))
.pipe(livereload());
});
gulp.task('watch', ['default'], function () {
livereload.listen();
var watcher = gulp.watch(moduleFiles.concat(staticFiles), ['default']);
watcher.on('change', function (event) {
if (event.type === 'deleted') {
delete cached.caches.scripts[event.path];
remember.forget('scripts', event.path);
}
});
});