Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

126 righe
3.1 KiB

  1. var del = require('del')
  2. , gulp = require('gulp')
  3. , chmod = require('gulp-chmod')
  4. , concat = require('gulp-concat')
  5. , header = require('gulp-header')
  6. , rename = require('gulp-rename')
  7. , size = require('gulp-size')
  8. , trim = require('gulp-trimlines')
  9. , uglify = require('gulp-uglify')
  10. , wrapUmd = require('gulp-wrap')
  11. , request = require('request')
  12. , fs = require('fs')
  13. , pkg = require('./package.json')
  14. var headerLong = ['/*!'
  15. , '* <%= pkg.name %> - <%= pkg.description %>'
  16. , '* @version <%= pkg.version %>'
  17. , '* <%= pkg.homepage %>'
  18. , '*'
  19. , '* @copyright <%= pkg.author %>'
  20. , '* @license <%= pkg.license %>'
  21. , '*'
  22. , '* BUILT: <%= pkg.buildDate %>'
  23. , '*/;'
  24. , ''].join('\n')
  25. var headerShort = '/*! <%= pkg.name %> v<%= pkg.version %> <%= pkg.license %>*/;'
  26. // all files in the right order (currently we don't use any dependency management system)
  27. var parts = [
  28. 'src/svg.js'
  29. , 'src/regex.js'
  30. , 'src/utilities.js'
  31. , 'src/default.js'
  32. , 'src/color.js'
  33. , 'src/array.js'
  34. , 'src/pointarray.js'
  35. , 'src/patharray.js'
  36. , 'src/number.js'
  37. , 'src/element.js'
  38. , 'src/fx.js'
  39. , 'src/boxes.js'
  40. , 'src/matrix.js'
  41. , 'src/point.js'
  42. , 'src/attr.js'
  43. , 'src/transform.js'
  44. , 'src/style.js'
  45. , 'src/parent.js'
  46. , 'src/ungroup.js'
  47. , 'src/container.js'
  48. , 'src/viewbox.js'
  49. , 'src/event.js'
  50. , 'src/defs.js'
  51. , 'src/group.js'
  52. , 'src/doc.js'
  53. , 'src/arrange.js'
  54. , 'src/mask.js'
  55. , 'src/clip.js'
  56. , 'src/gradient.js'
  57. , 'src/pattern.js'
  58. , 'src/shape.js'
  59. , 'src/bare.js'
  60. , 'src/symbol.js'
  61. , 'src/use.js'
  62. , 'src/rect.js'
  63. , 'src/ellipse.js'
  64. , 'src/line.js'
  65. , 'src/poly.js'
  66. , 'src/pointed.js'
  67. , 'src/path.js'
  68. , 'src/image.js'
  69. , 'src/text.js'
  70. , 'src/textpath.js'
  71. , 'src/nested.js'
  72. , 'src/hyperlink.js'
  73. , 'src/marker.js'
  74. , 'src/sugar.js'
  75. , 'src/set.js'
  76. , 'src/data.js'
  77. , 'src/memory.js'
  78. , 'src/selector.js'
  79. , 'src/helpers.js'
  80. , 'src/polyfill.js'
  81. ]
  82. gulp.task('clean', function() {
  83. return del([ 'dist/*' ])
  84. })
  85. /**
  86. * Compile everything in /src to one unified file in the order defined in the MODULES constant
  87. * wrap the whole thing in a UMD wrapper (@see https://github.com/umdjs/umd)
  88. * add the license information to the header plus the build time stamp‏
  89. */
  90. gulp.task('unify', ['clean'], function() {
  91. pkg.buildDate = Date()
  92. return gulp.src(parts)
  93. .pipe(concat('svg.js', { newLine: '\n' }))
  94. // wrap the whole thing in an immediate function call
  95. .pipe(wrapUmd({ src: 'src/umd.js'}))
  96. .pipe(header(headerLong, { pkg: pkg }))
  97. .pipe(trim({ leading: false }))
  98. .pipe(chmod(0o644))
  99. .pipe(gulp.dest('dist'))
  100. .pipe(size({ showFiles: true, title: 'Full' }))
  101. })
  102. /**
  103. ‎* uglify the file and show the size of the result
  104. * add the license info
  105. * show the gzipped file size
  106. */
  107. gulp.task('minify', ['unify'], function() {
  108. return gulp.src('dist/svg.js')
  109. .pipe(uglify())
  110. .pipe(rename({ suffix:'.min' }))
  111. .pipe(size({ showFiles: true, title: 'Minified' }))
  112. .pipe(header(headerShort, { pkg: pkg }))
  113. .pipe(chmod(0o644))
  114. .pipe(gulp.dest('dist'))
  115. .pipe(size({ showFiles: true, gzip: true, title: 'Gzipped' }))
  116. })
  117. gulp.task('default', ['clean', 'unify', 'minify'])