You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.1 KiB

  1. /*
  2. * grunt-contrib-uglify
  3. * http://gruntjs.com/
  4. *
  5. * Copyright (c) 2012 "Cowboy" Ben Alman, contributors
  6. * Licensed under the MIT license.
  7. */
  8. 'use strict';
  9. module.exports = function(grunt) {
  10. // Project configuration.
  11. grunt.initConfig({
  12. jshint: {
  13. all: [
  14. 'Gruntfile.js',
  15. 'tasks/**/*.js',
  16. '<%= nodeunit.tests %>'
  17. ],
  18. options: {
  19. jshintrc: '.jshintrc'
  20. }
  21. },
  22. // Before generating any new files, remove any previously-created files.
  23. clean: {
  24. tests: ['tmp']
  25. },
  26. // Configuration to be run (and then tested).
  27. uglify: {
  28. compress: {
  29. files: {
  30. 'tmp/compress.js': ['test/fixtures/src/simple.js']
  31. },
  32. options: {
  33. mangle: false
  34. }
  35. },
  36. compress_mangle: {
  37. files: {
  38. 'tmp/compress_mangle.js': ['test/fixtures/src/simple.js']
  39. }
  40. },
  41. compress_mangle_except: {
  42. files: {
  43. 'tmp/compress_mangle_except.js': ['test/fixtures/src/simple.js']
  44. },
  45. options: {
  46. mangle: {
  47. except: ['argumentC']
  48. }
  49. }
  50. },
  51. compress_mangle_beautify: {
  52. files: {
  53. 'tmp/compress_mangle_beautify.js': ['test/fixtures/src/simple.js']
  54. },
  55. options: {
  56. beautify: true
  57. }
  58. },
  59. multifile: {
  60. files: {
  61. 'tmp/multifile.js': ['test/fixtures/src/simple.js','test/fixtures/src/comments.js']
  62. },
  63. options: {
  64. mangle: false
  65. }
  66. },
  67. compress_mangle_sourcemap: {
  68. files: {
  69. '/dev/null': ['test/fixtures/src/simple.js']
  70. },
  71. options: {
  72. sourceMap: 'tmp/compress_mangle_sourcemap'
  73. }
  74. },
  75. sourcemapin: {
  76. files: {
  77. 'tmp/sourcemapin.js': ['test/fixtures/src/simple2.js']
  78. },
  79. options: {
  80. mangle : false,
  81. sourceMap: 'tmp/sourcemapin',
  82. sourceMapIn: 'test/fixtures/src/simple2.map',
  83. sourceMapRoot: 'http://local.host/js/'
  84. }
  85. },
  86. sourcemapurl: {
  87. files: {
  88. 'tmp/sourcemapurl.js': ['test/fixtures/src/simple.js']
  89. },
  90. options: {
  91. sourceMappingURL: 'js/sourcemapurl.js.map'
  92. }
  93. },
  94. comments: {
  95. src: 'test/fixtures/src/comments.js',
  96. dest: 'tmp/comments.js',
  97. options: {
  98. mangle: false,
  99. preserveComments: 'some'
  100. }
  101. },
  102. wrap: {
  103. src: 'test/fixtures/src/simple.js',
  104. dest: 'tmp/wrap.js',
  105. options: {
  106. mangle: false,
  107. wrap: 'testExport'
  108. }
  109. },
  110. exportAll: {
  111. src: 'test/fixtures/src/simple.js',
  112. dest: 'tmp/exportAll.js',
  113. options: {
  114. mangle: false,
  115. wrap: 'testExport',
  116. exportAll: true
  117. }
  118. },
  119. sourcemap_prefix: {
  120. files: {
  121. '/dev/null': ['test/fixtures/src/simple.js']
  122. },
  123. options: {
  124. sourceMap: 'tmp/sourcemap_prefix',
  125. sourceMapPrefix: 3
  126. }
  127. },
  128. multiple_sourcemaps: {
  129. files: {
  130. 'tmp/multiple_sourcemaps1.js': ['test/fixtures/src/simple.js'],
  131. 'tmp/multiple_sourcemaps2.js': ['test/fixtures/src/comments.js']
  132. },
  133. options: {
  134. sourceMap: function(dest) {
  135. return dest.replace(/\.js$/,".map");
  136. },
  137. sourceMappingURL: function(dest) {
  138. return dest.replace(/\.js$/,".mapurl");
  139. }
  140. }
  141. }
  142. },
  143. // Unit tests.
  144. nodeunit: {
  145. tests: ['test/*_test.js']
  146. }
  147. });
  148. // Actually load this plugin's task(s).
  149. grunt.loadTasks('tasks');
  150. // These plugins provide necessary tasks.
  151. grunt.loadNpmTasks('grunt-contrib-jshint');
  152. grunt.loadNpmTasks('grunt-contrib-clean');
  153. grunt.loadNpmTasks('grunt-contrib-nodeunit');
  154. grunt.loadNpmTasks('grunt-contrib-internal');
  155. // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  156. // plugin's task(s), then test the result.
  157. grunt.registerTask('test', ['clean', 'uglify', 'nodeunit']);
  158. // By default, lint and run all tests.
  159. grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
  160. };