Gulp.js event stream merge order

前端 未结 4 1762
渐次进展
渐次进展 2021-01-31 09:20

I am trying to merge css and scss files into a main.css file that goes in my build directory. Its working, but not in the right order. The style attributes from the scss files n

4条回答
  •  余生分开走
    2021-01-31 09:37

    I failed with all provided answers, they produced some silent errors. Finally merge2 worked for me (seems like there was gulp-merge and later the project was renamed into merge2). I'm not sure why there is a need in streamify plugin, e.g. streams created with Rollup may produce "stream-not-supported-errors" with gulp-concat, gulp-uglify or gulp-insert.

    const mergeStreams = require('merge2');
    const streamify = require('streamify');
    ...
    gulp.task('build', () => {
        const streams = sources.map(createJSFile);
        return mergeStreams(...streams)
            .pipe(streamify(concat('bundle.js')))
            .pipe(streamify(uglify()))
            .pipe(gulp.dest('./dist'));
    });
    

提交回复
热议问题