-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
gulpfile.js
115 lines (101 loc) · 3.12 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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));
var paths = {
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',
extraScripts: [
'./bower_components/smooth-scroll.js/dist/js/bind-polyfill.min.js',
'./bower_components/smooth-scroll.js/dist/js/smooth-scroll.min.js',
'./demo/scripts/prism.js',
'./demo/scripts/analytics.js'
],
stylesheets: {
css: './demo/stylesheets/**/*.css',
sass: './demo/stylesheets/**/*.sass'
},
temp: './demo/temp'
},
dist: {
scripts: './dist',
demo: './demo'
},
tests: './tests'
};
gulp.task('lint', function() {
return gulp.src(paths.app.all)
.pipe($.jshint())
.pipe($.jshint.reporter('default'));
});
gulp.task('test', function() {
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'))
.pipe($.streamify( $.uglify() ))
.pipe(gulp.dest(paths.dist.scripts))
});
gulp.task('demo', function() {
return browserify(paths.demo.entry, {
debug: argv.debug
})
.bundle()
.pipe(source('temp.js'))
.pipe(gulp.dest(paths.demo.temp))
});
gulp.task('sass', function () {
return gulp.src(paths.demo.stylesheets.sass)
.pipe($.rubySass())
.pipe($.autoprefixer())
.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'))
.pipe($.streamify( $.uglify() ))
.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'))
.pipe($.minifyCss())
.pipe(gulp.dest(paths.dist.demo))
});
gulp.task('watch', function() {
gulp.watch([paths.app.all, paths.app.ext], ['lint', 'scripts']);
});
gulp.task('watchSite', function() {
gulp.watch([paths.app.all, paths.app.ext], ['lint', 'scripts']);
gulp.watch(paths.demo.scripts, ['demo','js_concat']);
gulp.watch([paths.demo.stylesheets.sass, paths.demo.stylesheets.css], ['sass', 'css_concat']);
});
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' ] );