forked from pedroclayman/darts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
80 lines (67 loc) · 2.08 KB
/
Copy pathgulpfile.js
File metadata and controls
80 lines (67 loc) · 2.08 KB
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
var gulp = require('gulp');
var jsmin = require('gulp-jsmin');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var karma = require('gulp-karma');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var concatCss = require('gulp-concat-css');
var rename = require('gulp-rename');
gulp.task('default', ['copy-content','minify', 'scss-convert', 'test'], function(){
});
gulp.task('watch', ['test-watch'], function() {
gulp.watch('src/**/*.js', ['minify']);
gulp.watch('src/styles/**/*.scss', ['scss-convert']);
gulp.watch('src/index.html', ['copy-content']);
});
gulp.task('minify', function() {
gulp.src('src/**/*.js')
.pipe(concat('darts.js'))
.pipe(gulp.dest('dist'))
.pipe(jsmin())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
});
var test = function(shouldWatch) {
var testFiles = [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/angular-local-storage/dist/angular-local-storage.js',
'bower_components/angular-gravatar/build/md5.min.js',
'bower_components/angular-gravatar/build/angular-gravatar.min.js',
'src/app/app.js',
'src/app/controllers/**/*.js',
'src/app/directives/**/*.js',
'src/app/services/**/*.js',
'src/app/filters/**/*.js',
'tests/**/*.spec.js'
];
gulp.src(testFiles)
.pipe(karma({
configFile: 'karma.conf.js',
action: (shouldWatch === true ? 'watch' : 'run')
}))
.on('error', function(err) {
throw err;
});
}
gulp.task('test', function() {
test(false);
});
gulp.task('test-watch', function() {
test(true);
});
gulp.task('scss-convert', function() {
gulp.src('src/styles/**/*.scss')
.pipe(sass( { errLogToConsole: true } ))
.pipe(gulp.dest('dist/styles'))
.pipe(concatCss("darts.css"))
.pipe(gulp.dest('dist'))
.pipe(minifyCss())
.pipe(rename('darts.min.css'))
.pipe(gulp.dest('dist'));
});
gulp.task('copy-content', function() {
gulp.src('src/index.html')
.pipe(gulp.dest('dist'));
})