2014-03-02 2 views
1

정말 빠르게 보이는 Gulpjs를 사용해보고 싶습니다. Gulpjs의 다음 (일부) Gruntjs 구성을 번역하는 방법을 이해할 수 없습니다. 하나의 Gulpjs 작업에 이미 축소 된 파일을 추가하는 방법은 무엇입니까?

기본적 목적은 추하게 프로젝트 파일 플러스 일부 외부 종속성 (아직 축소 된) 하고 이미 축소 된 소스에 축약 과정을 방지하기 위해, 이미 축소 된 일부 종속성을 앞에 추가.

uglify: { 
    dist: { 
     src: [ 
      '<%= deps %>/bootstrap-daterangepicker/daterangepicker.js', 
      '<%= deps %>/smalot-bootstrap-datetimepicker/js/locales/*.js', 
      'src/js/**/*.js', 
     ], 
     dest: '<%= clean.dist %>/js/<%= pkg.name %>.min.js' 
    } 
}, 

concat: { 
    dist: { 
     src: [ 
      '<%= deps %>/jquery/dist/jquery.min.js', 
      '<%= deps %>/bootstrap/dist/js/bootstrap.min.js', 
      '<%= deps %>/momentjs/min/moment-with-langs.min.js', 
      '<%= uglify.dist.dest %>' 
     ], 
     dest: '<%= uglify.dist.dest %>' 
    } 
}, 

어떻게 Gulpjs에서 동일한 작업을 수행 할 수 있습니까? 이것은 가능한가?

처럼

는 지금 내 작업 (작동하지 않는, 결과는 jquery.min.js 단지 내용입니다) 모양 : 당신은 당신이 원하는 경우 "추하게"작업에서 스트림을 반환 (또는 another method을 사용) 할 필요가

gulp.task('uglify', function() { 
    gulp.src([ 
     './bower_components/bootstrap-daterangepicker/daterangepicker.js', 
     './bower_components/smalot-bootstrap-datetimepicker/js/locales/*.js', 
     './src/js/**/*.js' 
    ]) 
    .pipe(uglify()) 
    .pipe(concat('admin-template.js')) 
    .pipe(gulp.dest('./dist/js')); 
}); 

// Doesn't work 
gulp.task('concat', ['uglify'], function() { 
    gulp.src([ 
     'bower_components/jquery/dist/jquery.min.js', 
     './dist/js/admin-template.js' // output of uglify task 
    ]) 
    .pipe(concat('admin-template.js')) 
    .pipe(gulp.dest('./dist/js/')); 
}); 

답변

1

당신의 귀하의 "uglify"작업을 성공적으로 완료했는지에 따라 달라지는 "연결"작업.

어느 쪽이든, 확실히 이것을 단순화해야합니다.

아이디어가 있으시면 other SO thread을 참조하십시오. 아마도 gulp-if 나 event-stream을 사용할 것입니다.

그리고 여기뿐만 아니라 이상 봐 걸릴 : 유용한 resouces에 대한 https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md

+0

감사합니다. 나는 스트림 대기열에 갈 것이라고 생각한다. – gremo