This repository has been archived by the owner on Aug 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Gruntfile.js
164 lines (156 loc) · 4.6 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
'use strict';
/*global require:true, module:false*/
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
var swiper = {
filename: 'idangerous.swiper.scrollbar'
};
// Project configuration.
grunt.initConfig({
swiper: swiper,
// Metadata.
pkg: grunt.file.readJSON('bower.json'),
banner: '/*\n' +
' * Swiper Scrollbar <%= pkg.version %>\n' +
' * <%= pkg.description %>\n' +
' *\n' +
' * <%= pkg.homepage %>\n' +
' *\n' +
' * Copyright 2010-<%= grunt.template.today("yyyy") %>, <%= pkg.author %>\n' +
' * The iDangero.us\n' +
' * http://www.idangero.us/\n' +
' *\n' +
' * Licensed under <%= pkg.license.join(" & ") %>\n' +
' *\n' +
' * Released on: <%= grunt.template.today("mmmm d, yyyy") %>\n' +
'*/\n',
// Task configuration.
clean: {
dist: ['dist']
},
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
js: {
src: ['lib/<%= swiper.filename %>.js'],
dest: 'dist/<%= swiper.filename %>.js'
},
umd: {
src: ['<%= umd.lib.dest %>'],
dest: 'dist/<%= swiper.filename %>.amd.js'
},
css: {
src: ['lib/<%= swiper.filename %>.css'],
dest: 'dist/<%= swiper.filename %>.css'
}
},
copy: {
demos: {
files: [{
expand: true,
cwd: 'dist',
src: ['*.css'],
dest: 'demos/css'
},
{
expand: true,
cwd: 'dist',
src: ['*.js'],
dest: 'demos/js/'
}]
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
lib: {
src: ['dist/<%= swiper.filename %>.js'],
dest: 'dist/<%= swiper.filename %>.min.js',
},
umd: {
src: ['dist/<%= swiper.filename %>.amd.js'],
dest: 'dist/<%= swiper.filename %>.amd.min.js',
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
gruntfile: {
src: ['Gruntfile.js']
},
lib: {
src: ['lib/<%= swiper.filename %>.js']
},
},
umd: {
lib: {
src: '<%= jshint.lib.src %>',
dest: 'dist/<%= swiper.filename %>.umd.js',
amdModuleId: '<%= pkg.name %>',
objectToExport: 'Swiper',
indent: ' ',
deps: {
'default': ['swiper'],
'amd': ['swiper'],
'cjs': ['swiper'],
'global': ['Swiper']
}
}
},
wrap: {
js: {
src: ['<%= jshint.lib.src %>'],
dest: 'dist/<%= swiper.filename %>.js',
options: {
wrapper: [
'(function (Swiper) {\n',
'\n})(Swiper);'
],
indent: ' '
}
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib: {
files: '<%= jshint.lib.src %>',
tasks: ['jshint:lib']
}
}
});
// Default task.
this.registerTask('default', ['jshint', 'build']);
// Build a new version of the library
this.registerTask('build', 'Builds a distributable version of <%= pkg.name %>', [
'wrap:js',
'concat:js'
]);
this.registerTask('build-umd', 'Builds a umd compatible distributable version of <%= pkg.name %>', [
'umd:lib',
'concat:umd',
]);
this.registerTask('dist', 'Build dist of <%= pkg.name %>', [
'clean',
'jshint:lib',
'build',
'build-umd',
'uglify',
'concat:css'
]);
// Build demo
this.registerTask('demo', 'Builds demo of <%= pkg.name %>', [
'build',
'copy:demos'
]);
};