This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
gulpfile.js
147 lines (128 loc) · 4.69 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';
const del = require('del');
const gulp = require('gulp');
const coffee = require('gulp-coffee');
const concat = require('gulp-concat');
const declare = require('gulp-declare');
const handlebars = require('gulp-handlebars');
const jasmine = require('gulp-jasmine-phantom');
const less = require('gulp-less');
const minifyCss = require('gulp-minify-css');
const gutil = require('gulp-util');
const watch = require('gulp-watch');
const wrap = require('gulp-wrap');
const timestamp = new Date().getTime();
const paths = {
favicon: 'img/grails.logo.png',
app: {
css: {
debug: [
'/css/**/*.css'
],
release: [
`/css/app.${timestamp}.css`
]
},
js: {
debug: [
'/js/templates.js',
'/js/app/app.js',
'/js/app/*/**/*.js'
],
release: [
`/js/app.${timestamp}.js`
]
}
},
vendor: {
base: './web',
css: [
'/vendor/bootstrap/css/bootstrap.min.css',
'/vendor/font-awesome-4.0.3/css/font-awesome.css',
'/vendor/codemirror-5.25.2/lib/codemirror.css',
'/vendor/codemirror-5.25.2/theme/lesser-dark.css',
'/vendor/jquery-layout/css/jquery.layout.css',
'/vendor/jquery-ui-1.10.3/jquery-ui.min.css'
],
js: [
'/vendor/js/libs/jquery-1.7.1.min.js',
'/vendor/jquery-ui-1.10.3/jquery-ui.min.js',
'/vendor/bootstrap/js/bootstrap.min.js',
'/vendor/js/libs/underscore-min.js',
'/vendor/js/libs/backbone-min.js',
'/vendor/js/libs/backbone.marionette.min.js',
'/vendor/js/libs/handlebars.runtime-v4.0.5.js',
'/vendor/jquery-layout/js/jquery.layout-latest.min.js',
'/vendor/js/plugins/jquery.hotkeys.js',
'/vendor/codemirror-5.25.2/lib/codemirror.js',
'/vendor/codemirror-5.25.2/mode/groovy/groovy.js'
]
},
test: ['./js/tests/**.js']
};
require('./gulp-tasks/grails2')(gulp, paths);
require('./gulp-tasks/grails3')(gulp, paths);
gulp.task('clean', () => {
del.sync('./build');
});
gulp.task('templates', () => {
return gulp.src('./web/templates/**/*.hbs')
.pipe(handlebars({
handlebars: require('handlebars')
}))
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'JST',
processName: filePath => filePath.replace(/^.*web\/templates\//, '').replace(/\.js$/, '')
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest('./build/debug/js/'));
});
gulp.task('coffee:app', () => {
return gulp.src('./web/app/**/*.coffee')
.pipe(coffee({bare: false, join: false}).on('error', gutil.log))
.pipe(gulp.dest('./build/debug/js/app/'));
});
gulp.task('coffee:spec', () => {
return gulp.src('./web/spec/**/*.coffee')
.pipe(coffee({bare: false, join: false}).on('error', gutil.log))
.pipe(gulp.dest('./build/spec/'));
});
gulp.task('less', () => {
return gulp.src('./web/styles/**/*.less')
.pipe(less())
.pipe(gulp.dest('./build/debug/css/'));
});
gulp.task('concat:js', ['debug'], () => {
return gulp.src(paths.vendor.js.map(path => paths.vendor.base + path)
.concat(paths.app.js.debug.map(path => './build/debug' + path))
)
.pipe(concat(`app.${timestamp}.js`))
.pipe(gulp.dest('./build/release/js/'));
});
gulp.task('concat:css', ['debug'], () => {
return gulp.src(paths.app.css.debug.map(path => './build/debug' + path))
.pipe(minifyCss({keepBreaks: true}))
.pipe(concat(`app.${timestamp}.css`))
.pipe(gulp.dest('./build/release/css/'));
});
gulp.task('test', ['clean', 'templates', 'coffee:app', 'coffee:spec'], () => {
var vendorPaths = paths.vendor.js
.concat(['/vendor/js/plugins/jasmine-jquery.js'])
.map(path => paths.vendor.base + path)
.concat(paths.app.js.debug.map(path => './build/debug' + path));
return gulp.src('./build/spec/**/*spec.*')
.pipe(jasmine({
helpers: './build/spec/**/*helper.*',
integration: true,
vendor: vendorPaths
}));
});
gulp.task('watch', function () {
gulp.watch(['./web/**/*', 'gulpfile.js'], ['debug-all']);
});
gulp.task('debug', ['clean', 'templates', 'coffee:app', 'less']);
gulp.task('release', ['debug', 'concat:js', 'concat:css']);
gulp.task('debug-all', ['grails2:debug', 'grails3:debug']);
gulp.task('release-all', ['grails2:release', 'grails3:release']);
//gulp.task('default', ['build']);