This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
141 lines (132 loc) · 4.51 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
(function () {
"use strict";
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
port: LIVERELOAD_PORT
});
var livereloadMiddleware = function (connect, options) {
return [
lrSnippet,
connect.static(options.base),
connect.directory(options.base)
];
};
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> v<%= pkg.version %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['src/<%= pkg.name %>.js']
}
}
},
jshint: {
files: ['gruntfile.js', 'src/**/*.dev.js', 'test/spec/*.js', 'examples/**/*.js'],
options: {
smarttabs: true,
globals: {
jQuery: true,
console: true,
module: true,
document: true,
require: true
}
}
},
copy: {
dist: {
files: [{
src: ['src/<%= pkg.name %>.js'],
dest: 'example/'
}]
}
},
qunit: {
all: ['test/**/*.html']
},
compress: {
main: {
options: {
mode: 'gzip'
},
expand: true,
cwd: 'dist/',
src: ['<%= pkg.name %>.min.js'],
dest: 'dist/'
}
},
bumper: {
options: {
files: ['package.json'],
commit: false,
createTag: true,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
push: false,
runTasks: true,
tasks: ['jquerymanifest'],
}
},
'gh-pages': {
options: {
base: 'example',
message: 'Auto-generated commit for demo pages',
},
src: ['**']
},
connect: {
client: {
options: {
port: 9000,
base: 'example',
middleware: livereloadMiddleware,
open: true
}
}
},
watch: {
client: {
files: ['src/**/*.js', 'example/**/*.html', 'example/**/*.css'],
tasks: ['jshint', 'copy'],
options: {
livereload: LIVERELOAD_PORT
}
}
},
open: {
all: {
path: 'http://localhost:<%= connect.options.port%>'
}
},
jquerymanifest: {
options: {
source: grunt.file.readJSON('package.json'),
overrides: {
title: '<%= pkg.title %>',
},
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-bumper');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-jquerymanifest');
/*grunt.registerTask('test', ['jshint', 'qunit']);*/
grunt.registerTask('default', ['jshint', 'uglify', 'compress', 'copy']);
// Local server for development.
grunt.registerTask('server', ['jshint', 'copy', 'connect:client', 'watch:client']);
// Push to gh-pages branch
grunt.registerTask('push-demo', ['jshint', 'uglify', 'compress', 'copy', 'gh-pages']);
};
})();