-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathgulpfile.coffee
171 lines (149 loc) · 4.92 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
paths = require('./gulpfile_commons.coffee').paths
gulp = require('./gulpfile_commons.coffee').gulp
ngClassifyDefinitions = require('./gulpfile_commons.coffee').ngClassifyDefinitions
implementation_version = require('./gulpfile_commons.coffee').implementation_version
gutil = require 'gulp-util'
connect = require 'gulp-connect'
gulpif = require 'gulp-if'
coffee = require 'gulp-coffee'
concat = require 'gulp-concat'
tplCache = require 'gulp-angular-templatecache'
jade = require 'gulp-jade'
less = require 'gulp-less'
sourcemaps = require 'gulp-sourcemaps'
ngClassify = require 'gulp-ng-classify'
coffeelint = require 'gulp-coffeelint'
rimraf = require 'gulp-rimraf'
backend = require './backend/app'
protractor = require('gulp-protractor').protractor
paths.libJs = [
'./bower_components/jquery/jquery.js'
'./bower_components/angular/angular.js'
'./bower_components/angular-ui-router/release/angular-ui-router.js'
'./bower_components/angular-animate/angular-animate.js'
'./bower_components/angular-translate/angular-translate.js'
'./bower_components/angular-bootstrap/ui-bootstrap-tpls.js'
'./bower_components/underscore/underscore.js'
'./bower_components/angular-utf8-base64/angular-utf8-base64.js'
'./bower_components/bootstrap/dist/js/bootstrap.js'
'./bower_components/angulartics/src/angulartics.js'
'./bower_components/angulartics/src/angulartics-ga.js'
'./bower_components/SHA-1/sha1.js'
]
paths.libCss = [
'./app/css/bootstrap.css'
'./bower_components/font-awesome/css/font-awesome.css'
'./bower_components/octicons/octicons/css/octicons.css'
]
paths.minMaps = [
'./bower_components/angular/angular.min.js.map'
'./bower_components/angular-animate/angular-animate.min.js.map'
]
base =
paths: paths
gulp: gulp
destDir: './dist/'
gulp.task 'appJs', ->
gulp.src paths.appJs #tutte le sottocartelle di app con file .coffee o .js
.pipe coffeelint().on 'error', gutil.log
.pipe ngClassify(ngClassifyDefinitions) .on 'error', gutil.log
.pipe coffeelint.reporter().on 'error', gutil.log
.pipe sourcemaps.init().on 'error', gutil.log
.pipe (gulpif /[.]coffee$/, coffee(bare: true).on 'error', gutil.log).on 'error', gutil.log
.pipe concat('app.js').on 'error', gutil.log
.pipe sourcemaps.write('./maps').on 'error', gutil.log
.pipe gulp.dest(base.destDir + 'js').on 'error', gutil.log
gulp.task 'libJs', ->
gulp.src paths.libJs
.pipe concat 'lib.js'
.pipe gulp.dest base.destDir + 'js'
gulp.task 'minMaps', ->
gulp.src paths.minMaps
.pipe gulp.dest base.destDir + 'js/maps'
gulp.src './bower_components/underscore/underscore-min.map'
.pipe gulp.dest base.destDir + 'js'
gulp.task 'index', ->
gulp.src paths.index
.pipe gulpif /[.]jade$/, jade(
doctype: 'html'
locals: { 'version' : implementation_version }).on 'error', gutil.log
.pipe gulp.dest base.destDir
gulp.task 'templates', ->
gulp.src paths.templates
.pipe gulpif /[.]jade$/, jade(doctype: 'html').on 'error', gutil.log
.pipe tplCache 'templates.js', { standalone:true }
.pipe gulp.dest base.destDir + 'js/'
gulp.task 'appCss', ->
gulp.src paths.appCss
.pipe gulpif /[.]less$/, less
paths: []
.on 'error', gutil.log
.pipe concat 'style.css'
.pipe gulp.dest base.destDir + 'css'
gulp.task 'libCss', ->
gulp.src paths.libCss
.pipe concat 'lib.css'
.pipe gulp.dest base.destDir + 'css'
gulp.task 'img', ->
gulp.src paths.img
.pipe gulp.dest base.destDir
gulp.task 'favicon', ->
gulp.src paths.favicon
.pipe gulp.dest base.destDir
gulp.task 'fonts', ->
gulp.src paths.fonts
.pipe gulp.dest base.destDir + 'fonts'
gulp.task 'connect', ->
backend.initialize()
backend.start ->
# debug "Express server listening on port " + server.address().port
connect.server
root: ['dist']
port: 8000
livereload: true
gulp.task 'watch', ->
# reload connect server on built file change
gulp.watch [
'dist/**/*.html'
'dist/**/*.js'
'dist/**/*.css'
], (event) ->
gulp.src event.path
.pipe connect.reload()
# watch files to build
gulp.watch [
'./app/**/*.coffee'
'./app/**/*.js'],
['appJs']
gulp.watch [
'!./app/index.jade'
'!./app/index.html'
'./app/**/*.jade'
'./app/**/*.html'],
['templates']
gulp.watch ['./app/**/*.less','./app/**/*.css'], ['appCss']
gulp.watch ['./app/index.jade', './app/index.html'], ['index']
return
gulp.task 'libMap', ->
# copy sourcemaps for each libs
gulp.src [
'./bower_components/bootstrap/dist/css/bootstrap.css.map',
'./bower_components/font-awesome/css/font-awesome.css.map'
]
.pipe gulp.dest base.destDir + 'css'
gulp.task 'default', [
'appJs',
'libJs',
'minMaps',
'index',
'templates',
'appCss',
'libCss',
'img',
'favicon',
'fonts',
'libMap',
'connect',
'watch'
]
module.exports = base