forked from uxsolutions/bootstrap-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
101 lines (93 loc) · 3.34 KB
/
Gruntfile.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
/* global module, require */
module.exports = function(grunt){
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
qunit: {
all: ['tests/tests.html']
},
jshint: {
options: {
jshintrc: true
},
gruntfile: ['Gruntfile.js'],
main: ['js/bootstrap-datepicker.js'],
locales: ['js/locales/*js']
},
jscs: {
/* grunt-contrib-jscs notes:
0.1.2 works
0.1.3 infinite loops on postinstall
0.1.4 doesn't seem to hit all targets when run via "grunt jscs"
*/
gruntfile: ['Gruntfile.js'],
main: ['js/bootstrap-datepicker.js'],
locales: ['js/locales/*js']
},
sass: {
repo: {
files: {
'css/datepicker.css': 'scss/settings.scss'
}
}
},
uglify: {
options: {
compress: true,
mangle: true
},
main: {
options: {
sourceMap: function(dest){
return dest.replace('.min.js', '.min.js.map');
}
},
files: {
'js/bootstrap-datepicker.min.js': 'js/bootstrap-datepicker.js',
'js/bootstrap-datepicker.locales.min.js': 'js/locales/*.js'
}
}
// locales: {
// files: [{
// expand: true,
// cwd: 'js/locales/',
// src: ['*.js', '!*.min.js'],
// dest: '_build/locales/',
// rename: function(dest, name){
// return dest + name.replace(/\.js$/, '.min.js');
// }
// }]
// }
},
cssmin: {
all: {
files: {
'css/datepicker.min.css': 'css/datepicker.css'
}
}
},
clean: ['_build']
});
grunt.registerTask('lint', 'Lint all js files with jshint and jscs', ['jshint', 'jscs']);
// grunt.registerTask('test', 'Lint files and run unit tests', ['lint', 'qunit']);
grunt.registerTask('finish', 'Prepares repo for commit [lint, sass:repo, screenshots, cssmin, uglify]', ['lint', 'sass:repo', 'screenshots', 'cssmin', 'uglify']);
grunt.registerTask('screenshots', 'Rebuilds automated docs screenshots', function(){
var phantomjs = require('phantomjs').path;
grunt.file.recurse('docs/_static/screenshots/', function(abspath){
grunt.file.delete(abspath);
});
grunt.file.recurse('docs/_screenshots/', function(abspath, root, subdir, filename){
if (!/.html$/.test(filename))
return;
subdir = subdir || '';
var outdir = "docs/_static/screenshots/" + subdir,
outfile = outdir + filename.replace(/.html$/, '.png');
if (!grunt.file.exists(outdir))
grunt.file.mkdir(outdir);
grunt.util.spawn({
cmd: phantomjs,
args: ['docs/_screenshots/script/screenshot.js', abspath, outfile]
});
});
});
};