-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntFile.coffee
178 lines (159 loc) · 4.37 KB
/
gruntFile.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
172
173
174
175
176
177
178
module.exports = (grunt) ->
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks)
debug = !grunt.option("release")
grunt.initConfig
assets: grunt.file.readJSON('assets.json')
#server
go:
options:
GOPATH: ["../../../../../../../../../../../Users/zack/Dropbox/go"]
server:
root: "server"
output: "app"
run_files: ["main.go"]
#client
connect:
client:
options:
port: 31000
hostname: 'localhost'
base:'_dist'
middleware: (connect, options) ->
middlewares = []
middlewares.push(require('connect-modrewrite')([
'!\\.html|\\.js|\\.css|\\.otf|\\.eot|\\.svg|\\.ttf|\\.woff|\\.jpg|\\.bmp|\\.gif|\\.png|\\.txt$ /index.html'
]))
require('connect-livereload') port:31003
options.base.forEach (base) ->
middlewares.push(connect.static(base))
return middlewares
open:
server:
url:'http://localhost:31000'
watch:
options:
livereload: 31003
clientFile:
files: ['client/**/*','!client/**/*.coffee','!client/**/*.less']
tasks: ['newer:copy:client','sails-linker','replace:livereload']
clientCoffee:
files: ['client/**/*.coffee']
tasks: ['newer:coffee:client','sails-linker','replace:livereload']
coffee:
options:
bare: true
client:
files: [
expand: true
cwd: 'client/'
src: ['**/*.coffee']
dest: '_dist/'
ext: '.js'
]
uglify:
#options:
#mangle: false
#beautify: true
production:
files:
'_dist/index.js': ["<%= assets.js %>"]
cssmin:
production:
files:
'_dist/index.css': ["<%= assets.css %>"]
'sails-linker':
js:
options:
startTag: "<!--SCRIPTS-->"
endTag: "<!--SCRIPTS END-->"
fileTmpl: if debug then "<script src='/%s\'><\/script>" else "<script src='/%s?v=#{+new Date()}\'><\/script>"
appRoot: "_dist/"
files:
'_dist/index.html': if debug then ["<%= assets.js %>"] else "_dist/index.js"
css:
options:
startTag: "<!--STYLES-->"
endTag: "<!--STYLES END-->"
fileTmpl: if debug then "<link href='/%s' rel='stylesheet' />" else "<link href='/%s?v=#{+new Date()}' rel='stylesheet' />"
appRoot: "_dist/"
files:
'_dist/index.html': if debug then ["<%= assets.css %>"] else "_dist/index.css"
clean:
all:
src: "_dist/**/*"
redundant:
src: [
"_dist/*"
"!_dist/img"
"!_dist/*.*"
]
copy:
client:
files: [
expand: true
cwd: 'client/'
src: [
'**/*'
'!**/*.coffee'
]
dest: '_dist'
]
bower:
client:
dest: '_dist/vendor'
options:
expand: true
ngtemplates:
templates:
src: 'app/**/*.html'
dest: '_dist/common/templates.js'
cwd: '_dist'
options:
prefix: '/'
standalone: true
htmlmin:
collapseBooleanAttributes: true
collapseWhitespace: true
removeAttributeQuotes: true
removeComments: false
removeEmptyAttributes: true
removeRedundantAttributes: true
removeScriptTypeAttributes: true
removeStyleLinkTypeAttributes: true
replace:
livereload:
src: ["_dist/index.html"]
overwrite: true
replacements: [
from: '<!--LIVERELOAD-->'
to: '<script src="//localhost:31003/livereload.js"></script>'
]
concurrent:
tasks: ['go:run:server', 'watch', 'open']
options:
logConcurrentOutput: true
grunt.registerTask "build", ->
grunt.task.run [
"clean:all"
"bower"
"copy"
"coffee"
]
if debug
grunt.task.run [
"sails-linker"
"replace:livereload"
]
else
grunt.task.run [
"ngtemplates"
"uglify"
"cssmin"
"sails-linker"
"clean:redundant"
]
grunt.registerTask "default", [
'build'
'connect'
'concurrent'
]