This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Gruntfile.js
120 lines (101 loc) · 2.79 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
/*global module:false*/
var childProc = require("child_process");
module.exports = function(grunt) {
var pkg, minfiles = {},
lintFiles = ['Gruntfile.js', 'src/*.js', 'test/**/*.js'],
pluginNamespaces = [
"ajax",
"autoplay",
"drag",
"dynamic-containers",
"flip",
"keybd",
"loop",
"pagination",
"touch"
];
// Minify all the plugins
pluginNamespaces.forEach(function( namespace, i ) {
minfiles[ "dist/<%= pkg.name %>." + namespace + ".min.js" ] =
[ "dist/<%= pkg.name %>." + namespace + ".js" ];
});
// Minify the main concatenated files
minfiles[ "dist/<%= pkg.name %>.min.js" ] = [ "dist/<%= pkg.name %>.js" ];
// Project configuration.
grunt.initConfig({
pkg: pkg = grunt.file.readJSON('package.json'),
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
options: {
banner: '<%= meta.banner %>'
},
src: ['src/responsive-carousel.js', 'src/responsive-carousel.touch.js', 'src/responsive-carousel.drag.js', 'src/responsive-carousel.pagination.js', 'src/responsive-carousel.autoinit.js' ],
dest: 'dist/<%= pkg.name %>.js'
}
},
copy: {
plugins: {
files: [
{
expand: true,
// NOTE prevent overwritting by only pulling namespaced files
src: "src/*.*.js",
dest: "dist/",
filter: "isFile",
flatten: true
},
{
expand: true,
src: "src/*.css",
dest: "dist/",
filter: "isFile",
flatten: true
}
]
}
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
files: minfiles
}
},
watch: {
files: lintFiles,
tasks: 'jshint qunit'.split( " " )
},
jshint: {
all: lintFiles
},
qunit: {
all: [ "test/unit/responsive-carousel.html" ]
}
});
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.task.registerTask( "compress", "compress the dist folder", function() {
var done = this.async();
childProc.exec( "tar czf dist-" + pkg.version + ".tar.gz dist", function() {
done();
});
});
// Default task.
grunt.registerTask('default', 'jshint qunit copy:plugins concat uglify'.split( " " ));
// jenkins stage task.
grunt.registerTask('stage', 'jshint qunit copy:plugins concat uglify'.split( " " ));
// Travis
grunt.registerTask('travis', 'jshint qunit'.split( " " ));
};