Use new flarum-gulp package.

This commit is contained in:
Toby Zerner 2015-06-08 14:57:23 +09:30
parent b28bf04e5a
commit 1c80a509f1
4 changed files with 42 additions and 118 deletions

View File

@ -1,51 +1,20 @@
var gulp = require('gulp'); var gulp = require('flarum-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 merge = require('merge-stream');
var babel = require('gulp-babel');
var cached = require('gulp-cached');
var remember = require('gulp-remember');
var vendorFiles = [ gulp({
'../bower_components/loader.js/loader.js', files: [
'../bower_components/mithril/mithril.js', '../bower_components/loader.js/loader.js',
'../bower_components/jquery/dist/jquery.js', '../bower_components/mithril/mithril.js',
'../bower_components/moment/moment.js', '../bower_components/jquery/dist/jquery.js',
'../bower_components/bootstrap/dist/js/bootstrap.js', '../bower_components/moment/moment.js',
'../bower_components/spin.js/spin.js', '../bower_components/bootstrap/dist/js/bootstrap.js',
'../bower_components/spin.js/jquery.spin.js' '../bower_components/spin.js/spin.js',
]; '../bower_components/spin.js/jquery.spin.js'
],
var moduleFiles = [ moduleFiles: [
'src/**/*.js', 'src/**/*.js',
'../lib/**/*.js' '../lib/**/*.js'
]; ],
var modulePrefix = 'flarum'; bootstrapFiles: [],
modulePrefix: 'flarum',
gulp.task('default', function() { outputFile: 'dist/app.js'
return merge(
gulp.src(vendorFiles),
gulp.src(moduleFiles)
.pipe(cached('scripts'))
.pipe(babel({ modules: 'amd', moduleIds: true, moduleRoot: modulePrefix }))
.pipe(remember('scripts'))
)
.pipe(concat('app.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(vendorFiles), ['default']);
watcher.on('change', function (event) {
if (event.type === 'deleted') {
delete cached.caches.scripts[event.path];
remember.forget('scripts', event.path);
}
});
}); });

View File

@ -1,14 +1,7 @@
{ {
"private": true,
"devDependencies": { "devDependencies": {
"gulp": "^3.8.11", "gulp": "^3.8.11",
"gulp-babel": "^5.1.0", "flarum-gulp": "git+https://github.com/flarum/gulp.git"
"gulp-cached": "^1.0.4",
"gulp-concat": "^2.5.2",
"gulp-if": "^1.2.5",
"gulp-livereload": "^3.8.0",
"gulp-remember": "^0.3.0",
"gulp-uglify": "^1.2.0",
"merge-stream": "^0.1.7",
"yargs": "^3.7.2"
} }
} }

View File

@ -1,53 +1,22 @@
var gulp = require('gulp'); var gulp = require('flarum-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 merge = require('merge-stream');
var babel = require('gulp-babel');
var cached = require('gulp-cached');
var remember = require('gulp-remember');
var vendorFiles = [ gulp({
'../bower_components/loader.js/loader.js', files: [
'../bower_components/mithril/mithril.js', '../bower_components/loader.js/loader.js',
'../bower_components/jquery/dist/jquery.js', '../bower_components/mithril/mithril.js',
'../bower_components/jquery.hotkeys/jquery.hotkeys.js', '../bower_components/jquery/dist/jquery.js',
'../bower_components/color-thief/js/color-thief.js', '../bower_components/jquery.hotkeys/jquery.hotkeys.js',
'../bower_components/moment/moment.js', '../bower_components/color-thief/js/color-thief.js',
'../bower_components/bootstrap/dist/js/bootstrap.js', '../bower_components/moment/moment.js',
'../bower_components/spin.js/spin.js', '../bower_components/bootstrap/dist/js/bootstrap.js',
'../bower_components/spin.js/jquery.spin.js' '../bower_components/spin.js/spin.js',
]; '../bower_components/spin.js/jquery.spin.js'
],
var moduleFiles = [ moduleFiles: [
'src/**/*.js', 'src/**/*.js',
'../lib/**/*.js' '../lib/**/*.js'
]; ],
var modulePrefix = 'flarum'; bootstrapFiles: [],
modulePrefix: 'flarum',
gulp.task('default', function() { outputFile: 'dist/app.js'
return merge(
gulp.src(vendorFiles),
gulp.src(moduleFiles)
.pipe(cached('scripts'))
.pipe(babel({ modules: 'amd', moduleIds: true, moduleRoot: modulePrefix }))
.pipe(remember('scripts'))
)
.pipe(concat('app.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(vendorFiles), ['default']);
watcher.on('change', function (event) {
if (event.type === 'deleted') {
delete cached.caches.scripts[event.path];
remember.forget('scripts', event.path);
}
});
}); });

View File

@ -1,14 +1,7 @@
{ {
"private": true,
"devDependencies": { "devDependencies": {
"gulp": "^3.8.11", "gulp": "^3.8.11",
"gulp-babel": "^5.1.0", "flarum-gulp": "git+https://github.com/flarum/gulp.git"
"gulp-cached": "^1.0.4",
"gulp-concat": "^2.5.2",
"gulp-if": "^1.2.5",
"gulp-livereload": "^3.8.0",
"gulp-remember": "^0.3.0",
"gulp-uglify": "^1.2.0",
"merge-stream": "^0.1.7",
"yargs": "^3.7.2"
} }
} }