-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.coffee
153 lines (122 loc) · 3.24 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
module.exports = ( grunt ) ->
grunt.initConfig
target: './build'
source: './src'
public: '<%= target %>/public'
scripts: '<%= public %>/scripts'
# copies site files
copy:
content:
expand: true,
dest: '<%= target %>'
cwd: '<%= source %>'
src: ['**',
# skip processed files
'!**/*.{jade,coffee,sass}'] #,css,png,jpg}' ]
views:
expand: true,
dest: '<%= target %>'
cwd: '<%= source %>'
src: ['**/*.jade' ]
# compiles coffee script
coffee:
www:
expand: true,
cwd: '<%= source %>'
dest: '<%= target %>'
src: ['**/*.coffee']
ext: '.js'
# compiles jade to html
jade:
www:
expand: true,
cwd: '<%= source %>'
dest: '<%= target %>'
src: ['**/*.jade']
ext: '.html'
# compress css
cssmin:
www:
expand: true,
cwd: '<%= target %>'
dest: '<%= target %>'
src: [ 'public/**/*.css' ]
# javascript compression
uglify:
options:
mangle: false
www:
dest: '<%= public %>/app.js'
src: [ '<%= public %>/app.js' ]
# compiles coffee script
compass:
www:
options:
sassDir: '<%= source %>/public/ui'
cssDir: '<%= target %>/public/ui'
# environment: 'production'
# cleanup for deployment
clean:
start:
src: '<%= target %>/*'
# last cleanup before deploy
finish:
src:[
'<%= public %>/scripts'
]
# combine files
concat:
www:
src: [
# misc libraries
'<%= scripts %>/lib/*.js'
# order dependency
'<%= scripts %>/angular.js'
'<%= scripts %>/angular/*.js'
# initialize the app
'<%= scripts %>/init.js'
'<%= scripts %>/controllers/*.js'
'<%= scripts %>/filters/*.js'
'<%= scripts %>/components/*.js'
'<%= scripts %>/directives/*.js'
'<%= scripts %>/services/*.js'
]
dest: '<%= target %>/public/app.js'
# development ( auto deploy )
watch:
other:
expand: true
files: '<%= source %>/public/*'
tasks: [ 'copy' ]
options: { nospawn: true }
views:
expand: true
files: '<%= source %>/**/*.jade'
tasks: [ 'copy:views' ]
options: { nospawn: true }
scripts:
files: '<%= source %>/**/*.coffee'
tasks: [ 'coffee', 'concat' ]
options: { nospawn: true }
styles:
files: '<%= source %>/**/*.sass'
tasks: [ 'compass' ]
options: { nospawn: true }
# register tasks
for task in [
'grunt-iced-coffee',
'grunt-contrib-compass',
'grunt-contrib-cssmin',
'grunt-contrib-jade',
'grunt-contrib-copy',
'grunt-contrib-clean',
'grunt-contrib-concat',
'grunt-contrib-watch',
'grunt-contrib-uglify'
]
# load each task
grunt.loadNpmTasks task
# setup tasks
grunt.registerTask 'build', [ 'clean:start', 'copy', 'coffee', 'concat', 'compass' ]
grunt.registerTask 'deploy', [ 'build', 'uglify', 'cssmin', 'clean:finish' ]
grunt.registerTask 'auto', [ 'watch' ]