-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathGruntfile.js
153 lines (137 loc) · 4.15 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
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('asDatepicker.jquery.json'),
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(", ") %> */\n',
// Task configuration.
// -- clean config ----------------------------------------------------------
clean: {
files: ['dist']
},
// -- Concat Config ---------------------------------------------------------
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['src/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
},
},
// -- uglify Config ---------------------------------------------------------
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
},
},
// -- jsbeautifier Config ---------------------------------------------------
jsbeautifier : {
files : ["src/**/*.js"],
options : {
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"brace_style": "collapse",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"eval_code": false,
"indent_case": false,
"unescape_strings": false
}
},
// -- jshint config ----------------------------------------------------------
jshint: {
gruntfile: {
options: {
jshintrc: '.jshintrc'
},
src: 'Gruntfile.js'
},
src: {
options: {
jshintrc: 'src/.jshintrc'
},
src: ['src/**/*.js']
},
},
// -- watch config ----------------------------------------------------------
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
src: {
files: '<%= jshint.src.src %>',
tasks: ['jshint:src', 'qunit']
},
},
// -- less config ----------------------------------------------------------
less: {
dist: {
files: {
'css/asDatepicker.css': ['less/asDatepicker.less']
}
}
},
// -- autoprefixer config ----------------------------------------------------------
autoprefixer: {
options: {
browsers: ['last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12']
},
src: {
expand: true,
cwd: 'css/',
src: ['*.css', '!*.min.css'],
dest: 'css/'
}
},
// -- replace config ----------------------------------------------------------
replace: {
bower: {
src: ['bower.json'],
overwrite: true, // overwrite matched source files
replacements: [{
from: /("version": ")([0-9\.]+)(")/g,
to: "$1<%= pkg.version %>$3"
}]
},
jquery: {
src: ['asTabs.jquery.json'],
overwrite: true, // overwrite matched source files
replacements: [{
from: /("version": ")([0-9\.]+)(")/g,
to: "$1<%= pkg.version %>$3"
}]
},
},
});
// Load npm plugins to provide necessary tasks.
require('load-grunt-tasks')(grunt, {
pattern: ['grunt-*']
});
// Default task.
grunt.registerTask('default', ['jshint', 'clean', 'dist']);
grunt.registerTask('dist', ['concat', 'uglify']);
grunt.registerTask('js', ['jsbeautifier', 'jshint']);
grunt.registerTask('css', ['less', 'autoprefixer']);
grunt.registerTask('version', [
'replace:bower',
'replace:jquery'
]);
};