Gulp任务没有完成但工作正常

时间:2016-09-28 21:02:50

标签: javascript gulp

我运行下面的任务,任务没有完成,但任务正常。我使用手动回调但没有任何变化。

pythonic

结果:

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

感谢。

1 个答案:

答案 0 :(得分:0)

感谢。我发现问题。

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

必须从上次过滤器中删除还原选项。 (带有返回流的问题过滤器插件)

const fontFilter = plugin.filter('**/*.{ttf,woff,woff2,eot,svg}');
相关问题