2016-09-28 11 views
1

以下のタスクを実行すると、タスクは完了せずにタスクが正しく機能します。私は手動でコールバックを使用しますが、何も変わりません。Gulpタスクが完了しないが正しく動作する

gulp.task('compileSrc', 
    function() { 
     const imgFilter = plugin.filter('**/*.{jpg,png,gif}', {restore: true}); 
     const fontFilter = plugin.filter('**/*.{ttf,woff,woff2,eot,svg}', {restore: true}); 
     const cssFilter = plugin.filter('**/*.css', {restore: true}); 
     const jsFilter = plugin.filter('**/*.js', {restore: true}); 
     const htmlFilter = plugin.filter('**/*.html', {restore: true}); 

     return gulp.src([paths.src + '/css/**/*.css', paths.src + '/fonts/**/*', paths.src + '/img/**/*', paths.app + '/**/*']) 
     // CSS ****************************************************************** 
      .pipe(cssFilter) 
      .pipe(plugin.concat('app.css'))     // merge all css file to one file 
      // min css file 
      .pipe(
       plugin.minCss({ 
        compatibility: 'ie8', 
        keepSpecialComments: false 
       }) 
      ) 
      // rename css file 
      .pipe(
       plugin.rename({ 
        suffix: '.min' 
       }) 
      ) 
      .pipe(gulp.dest(paths.dist + '/src/css'))   // save to hard file 
      .pipe(cssFilter.restore) 
      // Html Template ****************************************************************** 
      .pipe(htmlFilter) 
      /* minify html */ 
      .pipe(
       plugin.minHtml({ 
        collapseWhitespace: true, 
        removeComments: true 
       }) 
      ) 
      /* convert html file to angular template cache */ 
      .pipe(
       plugin.templateCache({ 
        module: 'rainCrm', 
        root: paths.app 
       }) 
      ) 
      .pipe(htmlFilter.restore) 
      // JS ****************************************************************** 
      .pipe(jsFilter) 
      .pipe(plugin.ngAnnotate()) 
      .pipe(plugin.angularFilesort())   // sort angular files 
      .pipe(plugin.concat('app.js'))   // merge all js file to one file 
      .pipe(plugin.minJs())      // min js file 
      // rename js file 
      .pipe(
       plugin.rename({ 
        suffix: '.min' 
       }) 
      ) 
      .pipe(gulp.dest(paths.dist + '/src/js'))   // save to hard file 
      .pipe(jsFilter.restore) 
      // IMG ****************************************************************** 
      .pipe(imgFilter) 
      .pipe(gulp.dest(paths.dist + '/src/img'))   // save to hard file 
      .pipe(imgFilter.restore) 
      // FONT ****************************************************************** 
      .pipe(fontFilter) 
      .pipe(gulp.dest(paths.dist + '/src/fonts'));  // save to hard file 
    } 
); 

結果:正しい

[00:24:18] Starting 'compileSrc'... 

Process finished with exit code 0 

が、以下のタスク仕上げ。

/* compile libraries */ 
gulp.task('compileLibs', 
    function() { 
     const jsFilter = plugin.filter('**/*.js', {restore: true}); 
     const cssFilter = plugin.filter('**/*.css', {restore: true}); 

     return gulp.src(
      plugin.mainBowerFiles({ 
       overrides: { 
        "font-awesome": { 
         main: [ 
          "css/font-awesome.min.css", 
          "fonts/**/*" 
         ] 
        }, 
        "persian-date": { 
         main: [ 
          "dist/0.1.8/persian-date-0.1.8.js" 
         ] 
        } 
       } 
      }) 
     ) 
     // CSS ****************************************************************** 
      .pipe(cssFilter) 
      .pipe(plugin.concat('libs.css'))   // merge all css file to one file 
      // min css file 
      .pipe(
       plugin.minCss({ 
        compatibility: 'ie8', 
        keepSpecialComments: false 
       }) 
      ) 
      // rename css file 
      .pipe(
       plugin.rename({ 
        suffix: '.min' 
       }) 
      ) 
      .pipe(gulp.dest(paths.dist + '/src/css')) 
      .pipe(cssFilter.restore) 
      // JS ****************************************************************** 
      .pipe(jsFilter) 
      .pipe(plugin.concat('libs.js'))   // merge all js file to one file 
      .pipe(plugin.minJs())       // min js file 
      // rename css file 
      .pipe(
       plugin.rename({ 
        suffix: '.min' 
       }) 
      ) 
      .pipe(gulp.dest(paths.dist + '/src/js')) 
      .pipe(jsFilter.restore) 
      // FONTS ****************************************************************** 
      .pipe(plugin.filter('**/*.{ttf,woff,woff2,eot,svg,png,jpg,gif}')) 
      .pipe(gulp.dest(paths.dist + '/src/fonts')); 
    } 
); 

ありがとう。

+0

これは直接あなたの質問に答えていませんが、私は強く(すなわち '「compileSrcが」'で構成されている小さな論理的に凝集塊にあなたの一気のタスクを分割することをお勧めしますタスク "" compileStyles ""、 "" compileScripts ""、 "" compileResources "')を実行します。これを実行した後、問題はあなたに飛び出すでしょう。 – souldzin

答えて

0

ありがとうございました。私は問題を見つける。

const fontFilter = plugin.filter('**/*.{ttf,woff,woff2,eot,svg}', {restore: true}); 

最後のフィルタからリストアオプションを削除する必要があります。 (問題の戻りストリームとフィルタープラグイン)

const fontFilter = plugin.filter('**/*.{ttf,woff,woff2,eot,svg}'); 
関連する問題