terra/gulpfile.js

116 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2014-08-17 03:23:48 +00:00
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({lazy: false});
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var argv = require('minimist')(process.argv.slice(2));
2014-03-10 03:57:59 +00:00
var paths = {
2014-08-17 03:23:48 +00:00
app: {
entry: './app/main.js',
all: './app/**/*.js',
ext: ['./bower_components/**/*.js', './lodash_custom/**/*.js']
},
demo: {
entry: './demo/scripts/main.js',
scripts: './demo/scripts/**/*.js',
2014-08-17 06:23:39 +00:00
extraScripts: [
'./bower_components/smooth-scroll.js/dist/js/bind-polyfill.min.js',
'./bower_components/smooth-scroll.js/dist/js/smooth-scroll.min.js',
2014-08-23 17:49:20 +00:00
'./demo/scripts/prism.js',
'./demo/scripts/analytics.js'
2014-08-17 06:23:39 +00:00
],
stylesheets: {
css: './demo/stylesheets/**/*.css',
sass: './demo/stylesheets/**/*.sass'
},
temp: './demo/temp'
2014-08-17 03:23:48 +00:00
},
dist: {
scripts: './dist',
demo: './demo'
2014-08-17 03:23:48 +00:00
},
tests: './tests'
2014-03-10 03:57:59 +00:00
};
gulp.task('lint', function() {
2014-08-17 03:23:48 +00:00
return gulp.src(paths.app.all)
.pipe($.jshint())
.pipe($.jshint.reporter('default'));
2014-03-10 03:57:59 +00:00
});
gulp.task('test', function() {
2014-08-17 03:23:48 +00:00
return gulp.src(paths.tests)
.pipe( $.mocha( { reporter: 'spec' } ) )
});
gulp.task('scripts', ['lint'], function() {
return browserify(paths.app.entry, {
debug: argv.debug,
standalone: 'terra'
})
.bundle()
.pipe(source('terra.js'))
.pipe(gulp.dest(paths.dist.scripts))
.pipe($.rename('terra.min.js'))
2014-09-27 21:46:24 +00:00
.pipe($.streamify( $.uglify() ))
2014-08-17 03:23:48 +00:00
.pipe(gulp.dest(paths.dist.scripts))
2014-03-10 03:57:59 +00:00
});
2014-08-17 03:23:48 +00:00
gulp.task('demo', function() {
return browserify(paths.demo.entry, {
debug: argv.debug
})
.bundle()
2014-08-17 06:23:39 +00:00
.pipe(source('temp.js'))
.pipe(gulp.dest(paths.demo.temp))
2014-03-10 03:57:59 +00:00
});
gulp.task('sass', function () {
2014-08-17 06:23:39 +00:00
return gulp.src(paths.demo.stylesheets.sass)
2014-08-17 03:23:48 +00:00
.pipe($.rubySass())
.pipe($.autoprefixer())
2014-08-17 06:23:39 +00:00
.pipe(gulp.dest(paths.demo.temp))
});
gulp.task('js_concat', ['demo'], function () {
return gulp.src(paths.demo.extraScripts.concat(paths.demo.temp + '/*.js'))
.pipe($.concat('terra.demo.min.js'))
2014-09-27 21:46:24 +00:00
.pipe($.streamify( $.uglify() ))
2014-08-17 06:23:39 +00:00
.pipe(gulp.dest(paths.dist.demo))
});
gulp.task('css_concat', ['sass'], function () {
return gulp.src([paths.demo.stylesheets.css, paths.demo.temp + '/*.css'])
.pipe($.concat('main.css'))
2014-08-17 03:23:48 +00:00
.pipe($.minifyCss())
.pipe(gulp.dest(paths.dist.demo))
2014-03-10 03:57:59 +00:00
});
gulp.task('watch', function() {
2014-08-17 03:23:48 +00:00
gulp.watch([paths.app.all, paths.app.ext], ['lint', 'scripts']);
});
gulp.task('watchSite', function() {
gulp.watch([paths.app.all, paths.app.ext], ['lint', 'scripts']);
2014-08-17 06:23:39 +00:00
gulp.watch(paths.demo.scripts, ['demo','js_concat']);
gulp.watch([paths.demo.stylesheets.sass, paths.demo.stylesheets.css], ['sass', 'css_concat']);
2014-03-10 03:57:59 +00:00
});
gulp.task('deploy', function () {
gulp.src(paths.dist.demo + '/*.*')
.pipe($.ghPages('https://github.com/rileyjshaw/terra.git', 'origin'));
});
gulp.task('webserver', function() {
gulp.src(paths.dist.demo)
.pipe($.webserver({
host: '0.0.0.0',
livereload: true,
open: true
}));
});
gulp.task( 'default', [ 'lint', 'scripts', 'watch' ] );
gulp.task( 'site', [ 'lint', 'scripts', 'demo', 'js_concat', 'sass', 'css_concat', 'webserver', 'watchSite' ] );