-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
87 lines (81 loc) · 2.38 KB
/
gulpfile.coffee
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
gulp = require('gulp')
require('coffee-script/register')
concat = require('gulp-concat')
notify = require('gulp-notify')
header = require('gulp-header')
uglify = require('gulp-uglify')
notifier = require('node-notifier')
coffee = require('gulp-coffee')
gulpif = require('gulp-if')
watch = require('gulp-watch')
livereload = require('gulp-livereload')
less = require('gulp-less')
ngAnnotate = require('gulp-ng-annotate')
plumber = require('gulp-plumber')
uglifycss = require('gulp-uglifycss')
generatedFileWarning = '/* Warning! This is a generated file. Do not modify. Use Gulp task instead */\n'
distFolder = 'src/main/java/assets/dist'
jsBaseBuild =
gulp.src([
'src/main/java/app/**/*.coffee'
'src/main/java/app/**/*.js'
'!src/main/java/app/dist/**'
])
.pipe(gulpif(/[.]coffee$/, coffee({bare: true})))
gulp.task 'default', [
'build-js'
'build-css'
], ->
notifier.notify
title: 'Finished Resource Generation'
message: 'Done'
gulp.task 'watch', ->
gulp.start('default')
watch 'src/main/java/app/**/*.coffee', ->
gulp.start 'build-js'
watch 'src/main/java/app/**/*.js', ->
gulp.start 'build-js'
watch 'src/main/java/assets/css/**/*.css', ->
gulp.start 'build-css'
watch 'src/main/java/assets/less/**/*.less', ->
gulp.start 'build-css'
livereload.listen()
gulp.watch([distFolder]).on 'change', livereload.changed
gulp.task 'build-js', [
'concat-js'
'uglify-js'
], ->
gulp.task 'concat-js', ->
jsBaseBuild
.pipe(concat('main.js'))
.pipe(ngAnnotate())
.pipe(header(generatedFileWarning))
.pipe gulp.dest(distFolder)
.pipe(livereload())
gulp.task 'uglify-js', ->
jsBaseBuild
.pipe(concat('main.min.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(header(generatedFileWarning))
.pipe gulp.dest(distFolder)
gulp.task 'build-css', [
'concat-css'
'uglify-css'
], ->
gulp.task 'concat-css', ->
gulp.src(['src/main/java/assets/css/**/*.css'
'src/main/java/assets/less/style.less'])
.pipe(gulpif(/[.]less$/,less()))
.pipe(concat('main.css'))
.pipe(header(generatedFileWarning))
.pipe gulp.dest(distFolder)
.pipe(livereload())
gulp.task 'uglify-css', ->
gulp.src([distFolder + '/main.css'
'src/main/java/assets/less/style.less'])
.pipe(plumber())
.pipe(gulpif(/[.]less$/,less()))
.pipe(concat('main.min.css'))
.pipe(uglifycss())
.pipe gulp.dest(distFolder)