forked from ozzyogkush/solitaire-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
242 lines (224 loc) · 6.56 KB
/
Gruntfile.js
File metadata and controls
242 lines (224 loc) · 6.56 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/**
* Gruntfile for the Solitaire Webapp project. Automates and tests builds
* for development and production.
*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
paths : {
imageSrc : 'src/img',
bowerSrc : 'bower_components',
devOut : 'devbuild',
prodOut : 'prodbuild'
},
/*
First we compile the Bootstrap CSS files into the proper directory
Note: it also does not compress the CSS here!
*/
less : {
dev : {
options : {
paths: ['src/less', '<%= paths.bowerSrc %>/bootstrap/less']
},
files : {
'<%= paths.devOut %>/css/bootstrap.css' : 'src/less/main.less'
}
},
prod : {
options : {
paths: ['src/less', '<%= paths.bowerSrc %>/bootstrap/less']
},
files : {
'<%= paths.prodOut %>/css/bootstrap.css' : 'src/less/main.less'
}
}
},
/* Copy Bootstrap font files and image assets */
copy : {
dev : {
files : [
{
expand : true,
cwd : '<%= paths.bowerSrc %>/bootstrap/dist/fonts/',
src : '*.*',
dest : '<%= paths.devOut %>/fonts/'
},
{
expand : true,
cwd : '<%= paths.imageSrc %>/',
src : ['**/*.*'],
dest : '<%= paths.devOut %>/img/'
},
]
},
prod : {
files : [
{
expand : true,
cwd : '<%= paths.bowerSrc %>/bootstrap/dist/fonts/',
src : '*.*',
dest : '<%= paths.prodOut %>/fonts/'
},
{
expand : true,
cwd : '<%= paths.imageSrc %>/',
src : ['**/*.*'],
dest : '<%= paths.prodOut %>/img/'
},
]
}
},
/* Eventually I want to get Grunt to re-compile the complete Bootstrap source first before doing the above. */
/* Next we want to get all our JS dependencies brought into our JS folder */
bower_concat : { // jshint ignore:line
dev : {
// Dev assets go to /src
dest : "<%= paths.devOut %>/js/assets.js",
mainFiles : {
'joii' : [
'src/joii.js'
],
'color' : [
'Color.js'
]
},
include : [
'color',
'joii',
'jquery',
'bootstrap'
]
},
prod : {
// Dist assets go to /bin
dest : "<%= paths.prodOut %>/js/assets.js",
mainFiles : {
'joii' : [
'src/joii.js'
],
'color' : [
'Color.js'
]
},
include : [
'color',
'joii',
'jquery',
'bootstrap'
]
}
},
/* Concatanate all source JS files into a single application */
/* Interface definitions must come before any Class that uses them */
concat : {
options : {
separator : ';\r\n'
},
dev: {
// Dev assets go to /src
src: [
'src/js/exceptions/*.js',
'src/js/models/imodel-rules.js',
'src/js/models/*.js',
'src/js/views/iview-rules.js',
'src/js/views/*.js',
'src/js/static/*.js',
'src/js/games/*.js',
'src/js/controllers/*.js',
'src/js/*.js'
],
dest: '<%= paths.devOut %>/js/card-game-app.js'
},
prod: {
// Dist assets go to /bin
src: [
'src/js/exceptions/*.js',
'src/js/models/imodel-rules.js',
'src/js/models/*.js',
'src/js/views/iview-rules.js',
'src/js/views/*.js',
'src/js/static/*.js',
'src/js/games/*.js',
'src/js/controllers/*.js',
'src/js/*.js'
],
dest: '<%= paths.prodOut %>/js/card-game-app.js'
}
},
/* Minify files for production */
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
mangle : false
},
prod : {
files: [{
expand: true,
cwd: '<%= paths.prodOut %>/js/',
src: '*.js',
dest: '<%= paths.prodOut %>/js/',
ext: '.min.js'
}]
}
},
/* Set up our linter for JS files */
jshint : {
options : {
globals : {
curly : true, /* Force curly braces where optional */
jquery : true, /* Make jQuery globals available */
console : true, /* Make cnosole object global available */
module : true /* Make module object global available */
},
//undef : true, /* Variables must be defined before they can be used */
camelcase : true /* Variables and object properties must be camelCased */
},
dev : {
src : [
'dev_server.js',
'Gruntfile.js',
'src/js/**/*.js',
'unit-tests/**/*.js'
]
}
},
/* Set Up QUnit tests */
qunit : {
options : {
httpBase : 'http://localhost:8088'
},
test : {
src : [ 'unit-tests/**/*.html' ]
}
},
connect : {
/* Our qunit unit tests need a server to run on, so build one */
unitTests : {
options : {
hostname : 'localhost',
port: 8088,
base : '.'
}
}
}
});
// Load up all appropriate Tasks
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-bower-concat');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
/* Register our tasks */
// The development build will lint all JS, compile CSS from source, copy fonts, concatinate all dependency JS, and concatinate project source JS.
grunt.registerTask('dev', ['jshint:dev', 'less:dev', 'copy:dev', 'bower_concat:dev', 'concat:dev']);
// Just run unit tests without re-building the development source each time.
grunt.registerTask('unitTests', ['connect:unitTests', 'qunit:test']);
// The test build will build the development source and unit test that.
grunt.registerTask('test', ['dev', 'unitTests']);
// Our production build will first unit test all development code before producing production output.
grunt.registerTask('build', ['test', 'less:prod', 'copy:prod', 'bower_concat:prod', 'concat:prod', 'uglify:prod']);
};