forked from stucco/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
122 lines (110 loc) · 3.05 KB
/
grunt.js
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
/*global module:false*/
module.exports = function (grunt) {
// lint - uses [jshint](https://github.com/jshint/jshint/)
// jade - uses [jade](https://github.com/visionmedia/jade)
// min - uses [uglify-js](https://github.com/mishoo/UglifyJS)
// mincss - uses [csslint](https://github.com/stubbornella/csslint/wiki/Rules)
// load jade and other contributed tasks
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-mincss');
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
lint: {
files: ['source/assets/js/main.js']
},
copy: {
staticFiles: {
src: [ 'source/static/*'],
dest: 'deploy/'
},
img: {
src: [ 'source/assets/img/*'],
dest: 'deploy/img'
},
jquery: {
src: [ 'source/assets/js/jquery-1.8.2.min.js' ],
dest: 'deploy/js/'
},
data: {
src: [ 'data/*' ],
dest: 'deploy/data'
}
},
jade: {
compile: {
options: {
data: {
debug: true
}
},
files: {
'deploy/index.html': 'source/templates/index.jade',
'deploy/404.html': 'source/templates/404.jade'
}
}
},
min: {
app: {
src: ['source/assets/js/main.js',
'source/assets/js/jquery.tablesorter.js'],
dest: 'deploy/js/scripts.min.js'
}
},
mincss: {
'deploy/css/style.min.css': [
'source/assets/css/app.css'
]
},
concat: {
js: {
src: ['source/assets/js/main.js',
'source/assets/js/jquery.tablesorter.js'],
dest: 'deploy/js/scripts.min.js'
},
css: {
src: ['source/assets/css/app.css'],
dest: 'deploy/css/style.min.css'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint concat'
},
clean: [
'deploy'
],
jshint: {
options: {
laxcomma: true,
laxbreak: true,
asi: true,
browser: true
},
globals: {
jQuery: true
}
},
uglify: {
}
});
// Default task will be invoked when grunt is called without any argument
// concatenate but dont minify anything
grunt.registerTask('default', 'jade lint concat copy');
// run everything and minify
grunt.registerTask('prod', 'jade mincss lint min copy');
// clean deploy folder
grunt.registerTask('clean', 'clean');
// Copy is a separate task, since it does not need to be run as often
grunt.registerMultiTask('copy', 'Copy static files to deployment directory', function () {
var path = require("path"),
files = grunt.file.expand(this.file.src),
dest = this.file.dest;
grunt.log.writeln('Copying files for ' + this.target + '.');
files.forEach(function (file) {
grunt.file.copy(file, path.join(dest, path.basename(file)), {noProcess: true});
grunt.log.writeln('File "' + file + '" copied to "' + dest + '".');
});
});
};