Gruntfile.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module.exports = function (grunt) {
  2. function createBanner(fileName) {
  3. return '/*\n' +
  4. '* ' + fileName + '\n' +
  5. '* http://github.com/RobinHerbots/jquery.inputmask\n' +
  6. '* Copyright (c) 2010 - <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
  7. '* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)\n' +
  8. '* Version: <%= pkg.version %>\n' +
  9. '*/\n';
  10. }
  11. function createUglifyConfig(path) {
  12. var uglifyConfig = {};
  13. var srcFiles = grunt.file.expand(path + "/*.js");
  14. for (var srcNdx in srcFiles) {
  15. var dstFile = srcFiles[srcNdx].replace("js/", "");
  16. uglifyConfig[dstFile] = {
  17. dest: 'dist/inputmask/' + dstFile,
  18. src: srcFiles[srcNdx],
  19. options: { banner: createBanner(dstFile) }
  20. };
  21. }
  22. uglifyConfig["inputmaskbundle"] = {
  23. files: {
  24. 'dist/<%= pkg.name %>.bundle.js': srcFiles
  25. },
  26. options: { banner: createBanner('<%= pkg.name %>.bundle') }
  27. }
  28. return uglifyConfig;
  29. }
  30. // Project configuration.
  31. grunt.initConfig({
  32. pkg: grunt.file.readJSON('package.json'),
  33. uglify: createUglifyConfig("js"),
  34. clean: ["dist"],
  35. qunit: {
  36. files: ['qunit/qunit.html']
  37. }
  38. });
  39. // Load the plugin that provides the tasks.
  40. grunt.loadNpmTasks('grunt-contrib-uglify');
  41. grunt.loadNpmTasks('grunt-contrib-clean');
  42. grunt.loadNpmTasks('grunt-contrib-qunit');
  43. // Default task(s).
  44. grunt.registerTask('default', ['clean', 'uglify']);
  45. };