-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (83 loc) · 2.66 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
/**
* @author Lefthandmedia <[email protected]>
*/
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
bowerpath = 'bower_components/',
jsdest = '_js',
cssdest = '_css';
gulp.task('styles', function() {
return gulp.src('src/styles/*.scss')
.pipe(sass({ style: 'expanded' , sourcemap: true}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
//.pipe(gulp.dest(cssdest))
.pipe(rename({suffix: '.min'}))
//.pipe(minifycss())
.pipe(gulp.dest(cssdest))
//.pipe(notify({ message: 'Styles task complete' }))
;
});
gulp.task('libs', function() {
return gulp.src([bowerpath + 'jquery/dist/jquery.js',
bowerpath + 'angular/angular.js',
bowerpath + 'angular-route/angular-route.js'])
// .pipe(jshint('.jshintrc'))
//.pipe(jshint.reporter('default'))
.pipe(concat('libs.js'))
.pipe(gulp.dest(jsdest))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(jsdest))
//.pipe(notify({ message: 'Scripts task complete' }))
;
});
gulp.task('scripts', function() {
return gulp.src('src/scripts/**/*.js')
//.pipe(jshint('.jshintrc'))
//.pipe(jshint.reporter('default'))
.pipe(concat('app.js'))
.pipe(gulp.dest(jsdest))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(jsdest))
//.pipe(notify({ message: 'Scripts task complete' }))
;
});
gulp.task('app', function() {
return gulp.src('src/scripts/app.js', 'src/scripts/controllers/formcontroller.js', 'src/scripts/controllers/quizcontroller.js')
.pipe(concat('testapp.js'))
.pipe(gulp.dest(jsdest))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest(jsdest));
});
gulp.task('default', ['clean'], function() {
gulp.start('libs', 'styles', 'app', 'watch');
});
gulp.task('clean', function() {
return gulp.src([cssdest + '/*.css' , jsdest + '/*.js'], {read: false})
.pipe(clean());
});
gulp.task('watch', function() {
// Watch .scss files
gulp.watch('src/styles/**/*.scss', ['styles']);
// Watch .js files
gulp.watch('src/scripts/**/*.js', ['app']);
// Create LiveReload server
var server = livereload();
// Watch any files in dist/, reload on change
gulp.watch(['dist/**']).on('change', function(file) {
server.changed(file.path);
});
});