|
|
@@ -14,12 +14,16 @@ module.exports = function (grunt) {
|
|
|
var srcFiles = grunt.file.expand(path + "/*.js");
|
|
|
for (var srcNdx in srcFiles) {
|
|
|
var dstFile = srcFiles[srcNdx].replace("js/", "");
|
|
|
+ wrapAMDLoader(srcFiles[srcNdx], "build/" + dstFile, dstFile.indexOf("extension") == -1 ? ["jquery"] : ["jquery", "./jquery.inputmask"]);
|
|
|
uglifyConfig[dstFile] = {
|
|
|
dest: 'dist/inputmask/' + dstFile,
|
|
|
- src: srcFiles[srcNdx],
|
|
|
+ src: "build/" + dstFile,
|
|
|
options: { banner: createBanner(dstFile) }
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ srcFiles = grunt.file.expand(path + "/*.extensions.js");
|
|
|
+ srcFiles.splice(0, 0, "js/jquery.inputmask.js");
|
|
|
uglifyConfig["inputmaskbundle"] = {
|
|
|
files: {
|
|
|
'dist/<%= pkg.name %>.bundle.js': srcFiles
|
|
|
@@ -28,6 +32,20 @@ module.exports = function (grunt) {
|
|
|
}
|
|
|
return uglifyConfig;
|
|
|
}
|
|
|
+ function wrapAMDLoader(src, dst, dependencies) {
|
|
|
+ function stripClosureExecution() {
|
|
|
+ return srcFile.replace(new RegExp("\\(jQuery\\).*$"), "");
|
|
|
+ }
|
|
|
+
|
|
|
+ var srcFile = grunt.file.read(src),
|
|
|
+ dstContent = "(function (factory) {" +
|
|
|
+ "if (typeof define === 'function' && define.amd) {" +
|
|
|
+ "define(" + JSON.stringify(dependencies) + ", factory);" +
|
|
|
+ "} else {" +
|
|
|
+ "factory(jQuery);" +
|
|
|
+ "}}" + stripClosureExecution() + ");";
|
|
|
+ grunt.file.write(dst, dstContent);
|
|
|
+ }
|
|
|
|
|
|
// Project configuration.
|
|
|
grunt.initConfig({
|
|
|
@@ -43,6 +61,7 @@ module.exports = function (grunt) {
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
|
|
+ grunt.loadNpmTasks('grunt-contrib-requirejs');
|
|
|
|
|
|
// Default task(s).
|
|
|
grunt.registerTask('default', ['clean', 'uglify']);
|