Subversion-Projekte lars-tiefland.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
/*jshint node:true*/
2
module.exports = function( grunt ) {
3
 
4
"use strict";
5
 
6
var banner,
7
	umdStart,
8
	umdMiddle,
9
	umdEnd,
10
	umdStandardDefine,
11
	umdAdditionalDefine,
12
	umdLocalizationDefine;
13
 
14
banner = "/*!\n" +
15
	" * jQuery Validation Plugin v<%= pkg.version %>\n" +
16
	" *\n" +
17
	" * <%= pkg.homepage %>\n" +
18
	" *\n" +
19
	" * Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\n" +
20
	" * Released under the <%= _.map(pkg.licenses, 'type').join(', ') %> license\n" +
21
	" */\n";
22
 
23
// Define UMD wrapper variables
24
 
25
umdStart = "(function( factory ) {\n" +
26
	"\tif ( typeof define === \"function\" && define.amd ) {\n";
27
 
28
umdMiddle = "\t} else if (typeof module === \"object\" && module.exports) {\n" +
29
	"\t\tmodule.exports = factory( require( \"jquery\" ) );\n" +
30
	"\t} else {\n" +
31
	"\t\tfactory( jQuery );\n" +
32
	"\t}\n" +
33
	"}(function( $ ) {\n\n";
34
 
35
umdEnd = "return $;" +
36
	"\n}));";
37
 
38
umdStandardDefine = "\t\tdefine( [\"jquery\"], factory );\n";
39
umdAdditionalDefine = "\t\tdefine( [\"jquery\", \"./jquery.validate\"], factory );\n";
40
umdLocalizationDefine = "\t\tdefine( [\"jquery\", \"../jquery.validate\"], factory );\n";
41
 
42
grunt.initConfig( {
43
	pkg: grunt.file.readJSON( "package.json" ),
44
	concat: {
45
 
46
		// Used to copy to dist folder
47
		dist: {
48
			options: {
49
				banner: banner +
50
					umdStart +
51
					umdStandardDefine +
52
					umdMiddle,
53
				footer: umdEnd
54
			},
55
			files: {
56
				"dist/jquery.validate.js": [ "src/core.js", "src/*.js" ]
57
			}
58
		},
59
		extra: {
60
			options: {
61
				banner: banner +
62
					umdStart +
63
					umdAdditionalDefine +
64
					umdMiddle,
65
				footer: umdEnd
66
			},
67
			files: {
68
				"dist/additional-methods.js": [ "src/additional/additional.js", "src/additional/*.js" ]
69
			}
70
		}
71
	},
72
	uglify: {
73
		options: {
74
			preserveComments: false,
75
			banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
76
				"<%= grunt.template.today('m/d/yyyy') %>\n" +
77
				" * <%= pkg.homepage %>\n" +
78
				" * Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
79
				" Licensed <%= _.map(pkg.licenses, 'type').join(', ') %> */\n"
80
		},
81
		dist: {
82
			files: {
83
				"dist/additional-methods.min.js": "dist/additional-methods.js",
84
				"dist/jquery.validate.min.js": "dist/jquery.validate.js"
85
			}
86
		},
87
		all: {
88
			expand: true,
89
			cwd: "dist/localization",
90
			src: "**/*.js",
91
			dest: "dist/localization",
92
			ext: ".min.js"
93
		}
94
	},
95
	compress: {
96
		dist: {
97
			options: {
98
				mode: "zip",
99
				level: 1,
100
				archive: "dist/<%= pkg.name %>-<%= pkg.version %>.zip",
101
				pretty: true
102
			},
103
			src: [
104
				"changelog.txt",
105
				"demo/**/*.*",
106
				"dist/**/*.js",
107
				"Gruntfile.js",
108
				"lib/**/*.*",
109
				"package.json",
110
				"README.md",
111
				"src/**/*.*",
112
				"test/**/*.*"
113
			]
114
		}
115
	},
116
	qunit: {
117
		files: "test/index.html"
118
	},
119
	jshint: {
120
		options: {
121
			jshintrc: true
122
		},
123
		core: {
124
			src: "src/**/*.js"
125
		},
126
		test: {
127
			src: [ "test/*.js", "test/additional/*.js" ]
128
		},
129
		grunt: {
130
			src: "Gruntfile.js"
131
		}
132
	},
133
	watch: {
134
		options: {
135
			atBegin: true
136
		},
137
		src: {
138
			files: "<%= jshint.core.src %>",
139
			tasks: [
140
				"concat"
141
			]
142
		}
143
	},
144
	jscs: {
145
		all: [ "<%= jshint.core.src %>", "<%= jshint.test.src %>", "<%= jshint.grunt.src %>" ]
146
	},
147
	copy: {
148
		dist: {
149
			options: {
150
 
151
				// Append UMD wrapper
152
				process: function( content ) {
153
					return umdStart + umdLocalizationDefine + umdMiddle + content + umdEnd;
154
				}
155
			},
156
			src: "src/localization/*",
157
			dest: "dist/localization",
158
			expand: true,
159
			flatten: true,
160
			filter: "isFile"
161
		}
162
	},
163
	replace: {
164
		dist: {
165
			src: "dist/**/*.min.js",
166
			overwrite: true,
167
			replacements: [
168
				{
169
					from: "./jquery.validate",
170
					to: "./jquery.validate.min"
171
				}
172
			]
173
		}
174
	},
175
 
176
	// Generate the sub-resource integrity hashes of the distribution files
177
	sri: {
178
		options: {
179
			algorithms: [ "sha256", "sha384", "sha512" ],
180
 
181
			// The target json file
182
			dest: "dist/jquery-validation-sri.json",
183
 
184
			// Stringify the JSON output in a pretty format
185
			pretty: true
186
		},
187
 
188
		all: {
189
			src: [
190
				"dist/jquery.validate.{min.js,js}",
191
				"dist/additional-methods.{min.js,js}",
192
				"dist/localization/*.js"
193
			]
194
		}
195
	}
196
} );
197
 
198
grunt.loadNpmTasks( "grunt-contrib-jshint" );
199
grunt.loadNpmTasks( "grunt-contrib-qunit" );
200
grunt.loadNpmTasks( "grunt-contrib-uglify" );
201
grunt.loadNpmTasks( "grunt-contrib-concat" );
202
grunt.loadNpmTasks( "grunt-contrib-compress" );
203
grunt.loadNpmTasks( "grunt-contrib-watch" );
204
grunt.loadNpmTasks( "grunt-jscs" );
205
grunt.loadNpmTasks( "grunt-contrib-copy" );
206
grunt.loadNpmTasks( "grunt-text-replace" );
207
grunt.loadNpmTasks( "grunt-sri" );
208
 
209
grunt.registerTask( "default", [ "concat", "copy", "jscs", "jshint", "qunit" ] );
210
grunt.registerTask( "release", [ "default", "uglify", "replace", "compress", "sri" ] );
211
grunt.registerTask( "start", [ "concat", "watch" ] );
212
 
213
};