mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 02:10:09 +08:00
47 lines
1.3 KiB
JavaScript
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);
|
|
}
|
|
});
|
|
});
|