gulpfile-zip.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. module.exports = function(gulp, plugins) {
  2. var del = require('del'),
  3. log = console.log;
  4. var pkg = require('../package.json');
  5. gulp.task('zip_clean', function(){
  6. del.sync(['assets'])
  7. })
  8. gulp.task('zip_copySrc', function(){
  9. return gulp.src(['src/**'])
  10. .pipe(gulp.dest('assets/src'))
  11. })
  12. gulp.task('zip_copyDest', function(){
  13. return gulp.src(['dest/**', '!dest/**/*.html'])
  14. .pipe(gulp.dest('assets/dest'))
  15. })
  16. gulp.task('zip_trans', function() {
  17. var url = require('path').join('http://assets.dwstatic.com', pkg.description, pkg.name, pkg.version)
  18. return gulp.src(['dest/**/*.html'])
  19. .pipe( plugins.cdnAbsolutePath({assets:'dest', cdn:url}) )
  20. .pipe(gulp.dest('assets/dest'))
  21. })
  22. gulp.task('zip_done', ['zip_clean', 'zip_copySrc', 'zip_copyDest', 'zip_trans'], function() {
  23. return gulp.src(['assets/**'])
  24. .pipe(plugins.zip('assets.zip'))
  25. .pipe(gulp.dest('./'))
  26. })
  27. gulp.task('zip', ['zip_done'], function() {
  28. del.sync(['assets'])
  29. })
  30. }