Skip to content

Commit 3996b62

Browse files
committed
Merge pull request victorjonsson#395 from ray-print/160228/addUMDBoilerplate
Add universal module definition support (related to issue victorjonsson#329)
2 parents ba2ba34 + 2bf80b0 commit 3996b62

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

.npmignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#Testing, not relevant to end user
2+
test/
3+
.travis.yml
4+
.jshintrc
5+
6+
#Not relevant to npm users
7+
bower.json
8+
9+
#IDE
10+
.idea/

Gruntfile.js

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//TODO: During next major version bump change to /dist. Leaving at ./form-validator for backwards
22
//compatibility
33
const DIST_DIR = './form-validator';
4-
const MAIN_PLUGIN_FILE = './form-validator/jquery.form-validator.js';
4+
const MAIN_PLUGIN_FILE = './form-validator/jquery.form-validator';
55
const SRC_DIR = './src';
66
const MAIN_DIR = '/main/';
77
const MODULE_DIR = '/modules/';
@@ -79,7 +79,29 @@ function initializeGruntConfig(grunt, filesToBuild) {
7979
}
8080
},
8181

82-
clean: [DIST_DIR + '/']
82+
clean: [DIST_DIR + '/'],
83+
umd: {
84+
main: {
85+
options: {
86+
src: MAIN_PLUGIN_FILE + '.js',
87+
deps: {
88+
default: ['jQuery'],
89+
amd: [{'jquery': 'jQuery'}],
90+
cjs: [{'jquery': 'jQuery'}]
91+
}
92+
}
93+
},
94+
minified: {
95+
options: {
96+
src: MAIN_PLUGIN_FILE + '.min.js',
97+
deps: {
98+
default: ['$'],
99+
amd: [{'jquery': 'jQuery'}],
100+
cjs: [{'jquery': 'jQuery'}]
101+
}
102+
}
103+
}
104+
}
83105
});
84106
}
85107

@@ -89,7 +111,7 @@ module.exports = function (grunt) {
89111
concat: {
90112
main:{
91113
src: [SRC_DIR + MAIN_DIR+'core-validators.js'],
92-
dest: MAIN_PLUGIN_FILE
114+
dest: MAIN_PLUGIN_FILE + '.js'
93115
}
94116
}
95117
};
@@ -140,8 +162,8 @@ module.exports = function (grunt) {
140162
};
141163

142164
// Add main script to uglify
143-
filesToBuild.uglify[MAIN_PLUGIN_FILE] = {
144-
src: MAIN_PLUGIN_FILE,
165+
filesToBuild.uglify[MAIN_PLUGIN_FILE + '.js'] = {
166+
src: MAIN_PLUGIN_FILE + '.js',
145167
expand: true,
146168
extDot: 'last',
147169
ext: '.min.js'
@@ -183,7 +205,10 @@ module.exports = function (grunt) {
183205
grunt.loadNpmTasks('grunt-contrib-connect');
184206
grunt.loadNpmTasks('grunt-contrib-qunit');
185207
grunt.loadNpmTasks('grunt-contrib-cssmin');
186-
grunt.registerTask("build-production", ["version", "cssmin", "test", "uglify"]);
187-
grunt.registerTask('test', ['concat', 'cssmin','jshint', 'qunit']);
208+
grunt.loadNpmTasks('grunt-umd');
209+
210+
grunt.registerTask("build-production", ["version", "test", "uglify"]);
211+
grunt.registerTask('test', ['concat', 'umd', 'cssmin','jshint', 'qunit']);
188212
grunt.registerTask("default", ["test", "watch"]);
213+
grunt.registerTask("prepublish", ["test", "uglify"]);
189214
};

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"url": "git+https://github.com/victorjonsson/jQuery-Form-Validator.git"
1414
},
1515
"bugs": {
16-
"url": "https://github.com/jquery-boilerplate/jquery-boilerplate/issues"
16+
"url": "https://github.com/victorjonsson/jQuery-Form-Validator/issues"
1717
},
1818
"author": {
1919
"name": "Victor Jonsson",
@@ -33,6 +33,7 @@
3333
"grunt-contrib-qunit": "^0.7.0",
3434
"grunt-contrib-uglify": "~0.11.1",
3535
"grunt-contrib-watch": "^0.6.1",
36+
"grunt-umd": "~2.3.5",
3637
"jquery": "^2.1.4",
3738
"numeral": "~1.5.3",
3839
"qunitjs": "^1.20.0"
@@ -41,6 +42,7 @@
4142
"jquery": ">1.8.0"
4243
},
4344
"scripts": {
45+
"prepublish": "grunt prepublish",
4446
"test": "grunt test"
4547
}
4648
}

0 commit comments

Comments
 (0)