-
Notifications
You must be signed in to change notification settings - Fork 13
/
Gruntfile.js
98 lines (96 loc) · 3.73 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
const glob = require("glob");
module.exports = function (grunt) {
let buildNum = parseInt(grunt.option('build')) || 1;
console.log("BUILD_NUM:", buildNum);
grunt.initConfig({
uglify: {
'bundle': {
options: {
// beautify: true,
// mangle: false,
beautify: false,
mangle: true,
// sourceMap: true,
// sourceMapName: 'sourceMap.map'
},
src: [
'bustime/static/js/socket.io-2.0.4.js',
'bustime/static/js/jquery.js',
'bustime/static/js/jquery-ui.js',
'bustime/static/js/justgage.js',
'bustime/static/js/recorder.min.js',
'bustime/static/js/hotkeys.min.js',
'bustime/static/js/js.cookie.js',
'bustime/static/js/leaflet.js',
'bustime/static/maplibre/maplibre-gl.js',
'bustime/static/maplibre/leaflet-maplibre-gl.js',
'bustime/static/js/semantic.min.js',
'bustime/static/js/vue.global.prod.js',
'bustime/static/js/tablesort.js',
'bustime/static/js/jscolor.min.js',
'bustime/static/js/jquery.modal.min.js',
'bustime/static/js/common.js',
'bustime/static/js/bustime-main.js',
'bustime/static/js/bustime-main-entry.js',
],
dest: `bustime/static/js/bundle-built-${buildNum}.js`,
},
},
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
},
esversion: 6
},
all: [
'bustime/static/js/bustime_main.js',
'bustime/static/js/common.js',
'bustime/static/js/bustime-page.js',
'bustime/static/js/bustime-main-entry.js',
]
},
cssmin: {
options: {
mergeIntoShorthands: false,
roundingPrecision: -1
},
target: {
files: [{
src: [
"bustime/static/css/leaflet.css",
"bustime/static/css/semantic.min.css",
"bustime/static/css/font-awesome.min.css",
"bustime/static/css/jquery-ui.min.css",
"bustime/static/css/jquery.modal.min.css",
"bustime/static/maplibre/maplibre-gl.css",
"bustime/static/css/bustime-maplibre.css",
"bustime/static/css/bustime-main.css",
"bustime/static/css/bustime-page.css",
],
dest: `bustime/static/css/base-union-${buildNum}.css`
}]
}
},
});
function getBuildNum(regex) {
const glob = require("glob");
const paths = glob.sync(regex)
const buildNum = (paths.length > 0) ?
Math.max(...paths.map(o => {
let r = o.match(new RegExp('-(\\d+\).'));
return r ? r[1] : 0;
})) + 1 : 1;
console.log('Output:', regex.replace("*", buildNum));
return buildNum
}
// grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default', ['jshint', 'uglify']);
};