Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 /*jshint node:true*/
A 2 module.exports = function(grunt) {
3
4 "use strict";
5
6 grunt.initConfig({
7     pkg: grunt.file.readJSON('package.json'),
8     concat: {
9         // used to copy to dist folder
10         dist: {
11             files: {
12                 'dist/jquery.validate.js': ['jquery.validate.js'],
13                 'dist/additional-methods.js': ['additional-methods.js']
14             }
15         }
16     },
17     uglify: {
18         options: {
19             preserveComments: false,
20             banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
21                 '<%= grunt.template.today("m/d/yyyy") %>\\n' +
22                 '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
23                 '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
24                 ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
25         },
26         all: {
27             files: {
28                 'dist/jquery.validate.min.js': ['dist/jquery.validate.js'],
29                 'dist/additional-methods.min.js': ['dist/additional-methods.js']
30             }
31         }
32     },
33     zip: {
34         dist: {
35             src: [
36                 'dist/additional-methods.js',
37                 'dist/additional-methods.min.js',
38                 'dist/jquery.validate.js',
39                 'dist/jquery.validate.min.js',
40                 'README.md',
41                 'changelog.txt',
42                 'grunt.js',
43                 'package.json',
44                 'demo/**/*.*',
45                 'lib/**/*.*',
46                 'localization/**/*.*',
47                 'test/**/*.*'
48             ],
49             dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip'
50         },
51         options: {
52             zlib: {
53                 level: 1
54             }
55         }
56     },
57     qunit: {
58         files: ['test/index.html']
59     },
60     jshint: {
61         options: {
62             curly: true,
63             eqeqeq: true,
64             immed: true,
65             latedef: true,
66             newcap: true,
67             noarg: true,
68             sub: true,
69             undef: true,
70             eqnull: true,
71             browser: true,
72             globals: {
73                 jQuery: true,
74                 $: true,
75                 console: true
76             }
77         },
78         files: [
79             'jquery.validate.js',
80             'additional-methods.js',
81             'localization/*.js'
82         ],
83         test: {
84             options: {
85                 globals: {
86                     jQuery: true,
87                     $: true,
88                     QUnit: true,
89                     module: true,
90                     test: true,
91                     start: true,
92                     stop: true,
93                     expect: true,
94                     ok: true,
95                     equal: true,
96                     deepEqual: true,
97                     strictEqual: true
98                 }
99             },
100             files: {
101                 src: [
102                     'test/test.js',
103                     'test/rules.js',
104                     'test/messages.js',
105                     'test/methods.js'
106                 ]
107             }
108         },
109         grunt: {
110             files: {
111                 src: [
112                     'Gruntfile.js'
113                 ]
114             }
115         }
116     }
117 });
118
119 grunt.loadNpmTasks('grunt-contrib-jshint');
120 grunt.loadNpmTasks('grunt-contrib-qunit');
121 grunt.loadNpmTasks('grunt-contrib-uglify');
122 grunt.loadNpmTasks('grunt-contrib-concat');
123 grunt.loadNpmTasks('grunt-zipstream');
124
125 grunt.registerTask('default', ['jshint', 'qunit']);
126 grunt.registerTask('release', ['default', 'concat', 'uglify', 'zip']);
127
128 };