-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
104 lines (97 loc) · 2.64 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
var path = require('path');
module.exports = function(grunt) {
'use strict';
// copy recursively files from 'src' directory to 'dest' dir under vendor
var copyToVendor = function(src, dest) {
grunt.file.recurse(src, function(abs, root, sub, filename) {
var d = path.join('vendor', dest, sub || '', filename);
grunt.file.copy(abs, d, {
process: function(file, src) {
if(grunt.file.exists(d)) {
return false;
}
grunt.log.writeln('copying: ' + src + ' to ' + d);
return file;
}
});
});
};
grunt.initConfig({
watch: {
js: {
options: {
interrupt: true
},
files: ['es2015-src/*'],
tasks: ['build-dep', 'babel', 'build-bin', 'karma:dev']
}
},
karma: {
options: {
configFile: 'karma.conf.js',
browsers: ['Firefox'],
singleRun: true
},
dev: {
reporters: 'dots'
}
},
lodash: {
build: {
dest: 'vendor/lodash/lodash.js',
options: {
category: ['collection', 'function']
}
}
},
babel: {
build: {
options: {
presets: 'es2015'
},
files: [{
expand: true,
cwd: 'es2015-src',
src: ['*'],
dest: 'js-compiled',
ext: '.es6-compiled.js'
}]
}
},
uglify: {
options: {
mangle: true
},
jqtipnav: {
files: {
'build/jqtipnav.min.js': ['js-compiled/jqtipnav.es6-compiled.js']
}
}
},
cssmin: {
target: {
files: {
'build/jqtipnav.min.css': ['stylesheets/style.css']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-lodash');
// prepares project dependencies - copy jquery and lodash to vendor directory
grunt.registerTask('build-dep', 'prepare development dependencies', function() {
if(!grunt.file.exists('vendor/lodash/lodash.js') || !grunt.file.exists('vendor/lodash/lodash.min.js')) {
grunt.task.run('lodash');
}
copyToVendor('node_modules/skeleton-css/css', 'skeleton');
copyToVendor('node_modules/jquery/dist', 'jquery');
});
// build javascript binary in build/ directory
grunt.registerTask('build-bin', ['babel', 'uglify:jqtipnav']);
// build all the development and binary files (js & css)
grunt.registerTask('build', ['build-dep', 'babel', 'uglify:jqtipnav', 'cssmin']);
};