-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathGruntfile.js
76 lines (76 loc) · 3.26 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
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
bower_concat: {
all: {
dest: {
'js': 'uber/static/deps/combined.js',
'css': 'uber/static/deps/combined.css'
},
callback: function (mainFiles, component) {
if (component === 'select2') {
// the default select2 file doesn't contain full functionality and we want the full thing
return mainFiles.map(function(filepath) {
return filepath.replace('select2.js', 'select2.full.js');
});
} else if (component === 'jquery-ui') {
// jquery.select-to-autocomplete.js doesn't have a bower.json so we manually add it
// There's already a pull request to add bower support:
// https://github.com/JamieAppleseed/selectToAutocomplete/pull/93
return mainFiles.concat([
process.cwd() + '/bower_components/jquery-ui/themes/ui-lightness/jquery-ui.css',
process.cwd() + '/uber/static/deps/selectToAutocomplete/jquery.select-to-autocomplete.js'
]);
} else if (component === 'jquery') {
// jquery-datetextentry doesn't have a bower.json so we manually add it
// TODO: make a pull request to the jquery-datetextentry to give them bower support
return mainFiles.concat([
process.cwd() + '/uber/static/deps/jquery-datetextentry/jquery.datetextentry.js',
process.cwd() + '/uber/static/deps/jquery-datetextentry/jquery.datetextentry.css'
]);
} else {
return mainFiles;
}
}
}
},
uglify: {
options: {
mangle: false,
output: { comments: 'some' },
sourceMap: true
},
target: {
files: {
'uber/static/deps/combined.min.js': ['uber/static/deps/combined.js']
}
}
},
cssmin: {
options: {
sourceMap: true,
rebaseTo: 'uber/static/deps'
},
target: {
files: {
'uber/static/deps/combined.min.css': ['uber/static/deps/combined.css']
}
}
},
replace: {
correct_sourcemap: {
src: ['uber/static/deps/combined.min.css.map'],
overwrite: true,
replacements: [{
from: '"uber/static/deps/combined.css"',
to: '"/uber/static/deps/combined.css"'
}]
}
}
});
grunt.loadNpmTasks('grunt-bower-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('default', ['bower_concat', 'uglify', 'cssmin', 'replace']);
};