This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
129 lines (117 loc) · 3.04 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
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
module.exports = function(grunt) {
var jsFiles = ['Gruntfile.js'],
cssFiles = [],
fs = require('fs');
(function buildJSFileList(jsFiles) {
var loadBundle = function(bundle) {
var i = bundle.length,
fileInfo,
filePath;
while (i--) {
fileInfo = bundle[i];
filePath = typeof fileInfo == 'object' ? fileInfo.path : fileInfo;
if (/\.js$/.test(filePath))
jsFiles.push('js/' + filePath);
else if (/\.css$/.test(filePath)) {
if (/\.min\.css$/.test(filePath))
continue;
var path = 'js/' + filePath,
minPath = path.replace('.css', '.min.css'),
mtime = fs.lstatSync(path).mtime.getTime(),
minStats = fs.existsSync(minPath) && fs.lstatSync(minPath);
if (!minStats || mtime > minStats.mtime.getTime()) {
cssFiles.push(path);
if (/leaflet/.test(filePath))
console.log("minifying: " + path);
}
//else
// console.log("not minifying: " + path, "unmodified");
}
}
};
var bundles = grunt.file.readJSON('bundles.json');
for (var name in bundles) {
var bundle = bundles[name];
if (name == 'widgetsFramework') {
for (var fName in bundle) {
loadBundle(bundle[fName]);
}
}
else
loadBundle(bundle);
}
})(jsFiles);
grunt.initConfig({
jshint: {
files: jsFiles,
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true,
'_': true
},
asi: true,
boss: true,
funcscope: true,
loopfunc: true,
eqnull: true,
evil: true,
debug: true,
smarttabs: true,
"-W099": true,
"-W092": true,
"-W032": true,
"-W041": true,
expr: true,
shadow: true,
supernew: true,
sub: true,
laxcomma: true,
laxbreak: true
}
},
uglify: {
compress: {
expand: true,
src: jsFiles,
dest: 'test/',
ext: '.min.js',
flatten: false,
mangle: true
}
},
cssmin: {
minify: {
expand: true,
src: cssFiles,
ext: '.min.css'
}
}
});
// grunt.loadNpmTasks('grunt-contrib-jshint');
// grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
// grunt.loadNpmTasks('grunt-contrib-concat');
grunt.task.registerTask('default', [/*'jshint', 'uglify',*/ 'cssmin']);
};
/*
bower: {
dev: {
dest: 'js/lib'
}
},
bowerInstall: {
install: {
options: {
targetDir: './js/lib',
}
//just run 'grunt bower:install' and you'll see files from your Bower packages in lib directory
}
},
grunt.loadNpmTasks('grunt-bower-task');
grunt.renameTask("bower", "bowerInstall");
grunt.loadNpmTasks('grunt-bower');
*/