lychee/src/gulpfile.js

147 lines
3.0 KiB
JavaScript
Raw Normal View History

2014-07-18 20:09:15 +00:00
var gulp = require('gulp'),
2015-01-29 22:08:52 +00:00
plugins = require('gulp-load-plugins')(),
paths = {};
2014-07-18 20:09:15 +00:00
2014-10-21 11:12:49 +00:00
/* Error Handler -------------------------------- */
var catchError = function(err) {
console.log(err.toString());
this.emit('end');
}
/* View ----------------------------------------- */
paths.view = {
js: [
2015-01-29 22:10:12 +00:00
'../src/scripts/_gup.js',
2015-01-31 21:29:31 +00:00
'../src/scripts/build.js',
2014-10-10 21:30:10 +00:00
'../src/scripts/view/main.js'
2014-07-18 20:09:15 +00:00
],
2014-10-21 11:12:49 +00:00
scripts: [
2015-01-29 22:54:25 +00:00
'bower_components/jQuery/dist/jquery.min.js',
2015-01-31 21:29:31 +00:00
'../dist/_view--javascript.js'
2014-10-21 11:12:49 +00:00
]
}
gulp.task('view--js', function() {
2014-11-01 23:08:47 +00:00
var stream =
gulp.src(paths.view.js)
2015-02-16 19:26:10 +00:00
.pipe(plugins.babel())
2015-01-29 22:54:25 +00:00
.on('error', catchError)
2014-11-01 23:08:47 +00:00
.pipe(plugins.concat('_view--javascript.js', {newLine: "\n"}))
.pipe(gulp.dest('../dist/'));
return stream;
2014-10-21 11:12:49 +00:00
});
2015-01-31 21:29:31 +00:00
gulp.task('view--scripts', ['view--js'], function() {
2014-10-21 11:12:49 +00:00
2014-11-01 23:08:47 +00:00
var stream =
gulp.src(paths.view.scripts)
.pipe(plugins.concat('view.js', {newLine: "\n"}))
.pipe(plugins.uglify())
.on('error', catchError)
.pipe(gulp.dest('../dist/'));
return stream;
2014-10-21 11:12:49 +00:00
});
/* Main ----------------------------------------- */
paths.main = {
2014-07-18 20:09:15 +00:00
js: [
2014-10-10 21:30:10 +00:00
'../src/scripts/*.js'
2014-07-18 20:09:15 +00:00
],
2014-10-21 11:12:49 +00:00
scripts: [
2015-01-29 22:54:25 +00:00
'bower_components/jQuery/dist/jquery.min.js',
'bower_components/mousetrap/mousetrap.min.js',
'bower_components/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
'bower_components/basicContext/dist/basicContext.min.js',
'bower_components/basicModal/dist/basicModal.min.js',
2015-01-31 21:29:31 +00:00
'../dist/_main--javascript.js'
2014-10-21 11:12:49 +00:00
],
2014-10-21 12:55:44 +00:00
scss: [
'../src/styles/*.scss'
],
2014-10-21 11:12:49 +00:00
styles: [
'bower_components/basicContext/src/styles/main.scss',
'bower_components/basicModal/src/styles/main.scss',
2014-10-10 21:30:10 +00:00
'../src/styles/main.scss'
2014-07-18 20:09:15 +00:00
]
}
2014-10-21 11:12:49 +00:00
gulp.task('main--js', function() {
2014-11-01 23:08:47 +00:00
var stream =
gulp.src(paths.main.js)
2015-02-16 19:26:10 +00:00
.pipe(plugins.babel())
2015-01-29 22:54:25 +00:00
.on('error', catchError)
2014-11-01 23:08:47 +00:00
.pipe(plugins.concat('_main--javascript.js', {newLine: "\n"}))
.pipe(gulp.dest('../dist/'));
return stream;
2014-10-21 11:12:49 +00:00
});
2015-01-31 21:29:31 +00:00
gulp.task('main--scripts', ['main--js'], function() {
2014-07-18 20:09:15 +00:00
2014-11-01 23:08:47 +00:00
var stream =
gulp.src(paths.main.scripts)
.pipe(plugins.concat('main.js', {newLine: "\n"}))
.pipe(plugins.uglify())
.on('error', catchError)
.pipe(gulp.dest('../dist/'));
return stream;
2014-07-18 20:09:15 +00:00
});
2014-10-21 11:12:49 +00:00
gulp.task('main--styles', function() {
2014-11-01 23:08:47 +00:00
var stream =
gulp.src(paths.main.styles)
.pipe(plugins.sass())
.on('error', catchError)
.pipe(plugins.concat('main.css', {newLine: "\n"}))
.pipe(plugins.autoprefixer('last 4 versions', '> 5%'))
.pipe(plugins.minifyCss())
.pipe(gulp.dest('../dist/'));
return stream;
2014-07-18 20:09:15 +00:00
});
2014-10-21 11:12:49 +00:00
/* Clean ----------------------------------------- */
2014-07-18 20:09:15 +00:00
2014-10-21 11:12:49 +00:00
gulp.task('clean', function() {
2014-11-01 23:08:47 +00:00
var stream =
gulp.src('../dist/_*.*', { read: false })
.pipe(plugins.rimraf({ force: true }))
.on('error', catchError);
return stream;
2014-07-18 20:09:15 +00:00
});
2014-10-21 11:12:49 +00:00
/* Tasks ----------------------------------------- */
2014-11-01 23:08:47 +00:00
gulp.task('default', ['view--scripts', 'main--scripts', 'main--styles'], function() {
gulp.start('clean');
});
2014-07-18 20:09:15 +00:00
gulp.task('watch', ['default'], function() {
2014-10-21 11:12:49 +00:00
2014-11-01 23:22:17 +00:00
gulp.watch(paths.view.js, ['view--scripts']);
2014-10-21 11:12:49 +00:00
2014-11-01 23:22:17 +00:00
gulp.watch(paths.main.js, ['main--scripts']);
gulp.watch(paths.main.scss, ['main--styles']);
2014-10-21 11:12:49 +00:00
2014-07-18 20:09:15 +00:00
});