-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
111 lines (87 loc) · 2.96 KB
/
gulpfile.js
File metadata and controls
111 lines (87 loc) · 2.96 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
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
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
minifyHTML = require('gulp-minify-html'),
spawn = require('child_process').spawn,
gutil = require('gulp-util');
/** Major Tasks **/
// Default
gulp.task('default', ['build', 'connect'], function () {
gulp.watch(['src/**/*.*js'], ['js']);
gulp.watch(['src/**/*.html'], ['html']);
gulp.watch(['src/css/**/*.*scss'], ['css']);
gulp.watch(['bower_components', 'index.html'], ['copy']);
gulp.watch(['index.html', 'dist/**/**.*'], function (event) {
return gulp.src(event.path)
.pipe($.connect.reload());
});
});
gulp.task('parse', ['build', 'parse-no-build'], function(){
// to be run from the command line
});
// can be inserted as dependency after a build task
gulp.task('parse-no-build', function(){
gulp.src('dist/**')
.pipe(gulp.dest('parse/public'));
});
// Test
gulp.task('test', ['casperTest'], function () {
});
/** Sub Tasks **/
// Build
gulp.task('build', ['js', 'html', 'css', 'copy']);
// JS
gulp.task('js', function () {
gulp.src(['src/components/base/Class.js', 'src/components/base/*', 'src/**/*.*js'])
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.concat('app.js'))
//.pipe($.ngAnnotate())
// .pipe($.uglify())
.pipe($.sourcemaps.write())
.pipe(gulp.dest('dist'));
});
// HTML
gulp.task('html', function () {
gulp.src('src/partials/**/*.*html')
.pipe(minifyHTML())
.pipe(gulp.dest('dist/partials'));
});
// CSS
gulp.task('css', function () {
$.rubySass('src/css/main.scss', {quiet: true})
.pipe($.autoprefixer("last 2 versions", "> 1%"))
.pipe(gulp.dest('dist/css'));
});
// Copy
gulp.task('copy', function () {
gulp.src([
'bower_components/angular/angular.min.*',
'bower_components/angular-cookies/angular-cookies.min.*',
'bower_components/angular-ui-router/release/angular-ui-router.min.js',
'bower_components/angular-animate/angular-animate.min.*'
]).pipe(gulp.dest('dist/bower_components'));
gulp.src(['fonts/**/**']).pipe(gulp.dest('dist/font'));
gulp.src(['index.html']).pipe(gulp.dest('dist'));
gulp.src(['images/**/**']).pipe(gulp.dest('dist/images'));
gulp.src(['appcodes.js']).pipe(gulp.dest('dist'));
});
// Connect - Port 8002
gulp.task('connect', function () {
$.connect.server({
root: [__dirname + "/dist"],
port: 8002,
livereload: {port: 2983}
});
});
// Casper Tests
gulp.task('casperTest', function () {
var tests = ['tests/casper/casperTest.js', 'tests/casper/resurrectioTest.js'];
var casperChild = spawn('casperjs', ['test'].concat(tests));
casperChild.stdout.on('data', function (data) {
gutil.log('CasperJS:', data.toString().slice(0, -1));
});
casperChild.on('close', function (code) {
var success = code === 0; // Will be 1 in the event of failure
// Do something with success here
});
});