-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
60 lines (54 loc) · 1.77 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
cleanCSS = require('gulp-clean-css'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify');
// Configs
var combineJSName = 'angular-ask.js';
var autoprefixerConfig = {
browsers: ['last 2 versions', 'Android >= 4.0'],
cascade: true,
remove: true
}
gulp.task('style', function(){
return gulp.src('styles/sass/*.scss')
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer(autoprefixerConfig))
.pipe(gulp.dest('styles/css'))
.pipe(rename({ suffix: '.min'}))
.pipe(cleanCSS())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('styles/css'))
});
gulp.task('js', function(){
return gulp.src('scripts/src/*.js')
.pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
.pipe(sourcemaps.init())
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat(combineJSName))
.pipe(gulp.dest('scripts/dist'))
.pipe(rename({ suffix: '.min'}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('scripts/dist'))
});
gulp.task('vendor', function(){
return gulp.src(['node_modules/jquery/dist/jquery.min.js', 'node_modules/jquery/dist/jquery.min.map', 'node_modules/angular/angular.min.js', 'node_modules/angular/angular.min.js.map'])
.pipe(gulp.dest('scripts/vendor'))
});
gulp.task('watch', function(){
gulp.watch('styles/sass/*.scss', ['style']);
gulp.watch('scripts/src/*.js', ['js']);
});
gulp.task('default', function(){
gulp.start('style', 'vendor', 'js', 'watch');
});