-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.coffee
107 lines (91 loc) · 3.09 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
gulp = require 'gulp'
gutil = require 'gulp-util'
coffee = require 'gulp-coffee'
coffeelint = require 'gulp-coffeelint'
jst = require 'gulp-template-compile'
concat = require 'gulp-concat'
rename = require 'gulp-rename'
uglify = require 'gulp-uglify'
sourcemaps = require 'gulp-sourcemaps'
minifycss = require 'gulp-minify-css'
server = require 'gulp-webserver'
del = require 'del'
sequence = require 'run-sequence'
tar = require 'gulp-tar'
gzip = require 'gulp-gzip'
karma = require('karma').server
config =
name: 'skeleton'
version: '1.0.0'
gulp.task 'clean', (cb) ->
del ['dist'], cb
gulp.task 'lib', ->
gulp.src('lib/**')
.pipe(gulp.dest('dist/assets/lib'))
gulp.task 'scripts', ->
gulp.src('src/main/app/coffee/**/*.coffee')
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(sourcemaps.init())
.pipe(coffee({ bare: true }).on('error', gutil.log))
.pipe(concat('app.js'))
.pipe(rename({ suffix: '-' }))
.pipe(rename({ suffix: config.version }))
.pipe(gulp.dest('dist/assets/app/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/assets/app/js'))
gulp.task 'templates', ->
gulp.src('src/main/app/templates/**/*.html')
.pipe(jst(
namespace: 'SkeletonTemplates'
name: (file) -> file.relative.replace /\.html$/, ''
))
.pipe(concat('app-templates.js'))
.pipe(rename({ suffix: '-' }))
.pipe(rename({ suffix: config.version }))
.pipe(gulp.dest('dist/assets/app/js'))
gulp.task 'html', ->
gulp.src(['src/main/app/*.html', '!src/main/app/styleguide.html'])
.pipe(gulp.dest('dist'))
gulp.task 'stylehtml', ->
gulp.src('src/main/app/styleguide.html')
.pipe(gulp.dest('dist'))
gulp.task 'css', ->
gulp.src('src/main/app/css/**/*.css')
.pipe(gulp.dest('dist/assets/app/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('dist/assets/app/css'))
gulp.task 'images', ->
gulp.src('src/main/app/img/**/*')
.pipe(gulp.dest('dist/assets/app/img'))
gulp.task 'tar', ->
gulp.src('dist/**')
.pipe(tar("#{config.name}.tar"))
.pipe(gzip())
.pipe(gulp.dest('dist'))
gulp.task 'unittest', ->
karma.start
configFile: __dirname + '/karma.conf.coffee'
singleRun: true
gulp.task 'default', ['clean'], ->
gulp.start 'lib', 'templates', 'scripts', 'html', 'css', 'images'
gulp.task 'dist', ['clean'], ->
sequence ['lib', 'templates', 'scripts', 'html', 'css', 'images'], 'tar'
gulp.task 'run', ['lib', 'templates', 'scripts', 'html', 'stylehtml', 'css', 'images'], ->
gulp.watch 'src/main/app/templates/**/*.html', ['templates']
gulp.watch 'src/main/app/coffee/**/*.coffee', ['scripts']
gulp.watch 'src/main/app/*.html', ['html']
gulp.watch 'src/main/app/styleguide.html', ['stylehtml']
gulp.watch 'src/main/app/css/**/*.css', ['css']
gulp.watch 'src/main/app/img/**/*', ['images']
gulp.watch 'lib/**', ['lib']
gulp.src('dist')
.pipe(server(
port: 9000
livereload: true
))
gulp.task 'test', ['clean'], ->
sequence ['lib', 'templates', 'scripts', 'html', 'css', 'images'], 'unittest'