我在gulp任务管道中有以下任务:
var config = require('../build-config')
var gulp = require('gulp')
var spritesmith = require('gulp.spritesmith')
var path = require('path')
var merge = require('merge-stream');
var paths = {
// image source location
src: path.join(config.root.src,config.tasks.images.src,'**/*.{' + config.tasks.images.extensions.join(',') + '}'),// final destination file location
dest: path.join(config.root.dest,config.tasks.images.dest),// describe how to make the file
handlebarsTemplateSrc: path.join(config.root.src,'handlebarsStr.css.handlebars'),// all the styles files
styleDest: path.join(config.root.src,config.tasks.images.generatedStyleDest),}
// for task 'images'
gulp.task('images',function() {
console.log(paths);
var spriteData = gulp.src(paths.src).pipe(spritesmith({
// final destination file name
imgName: 'sprite.png',// use this as style for every input file
cssname: 'sprites.less',// describe how to make the file
cssTemplate: paths.handlebarsTemplateSrc
}));
var imgStream = spriteData.img.pipe(gulp.dest(paths.dest));
var cssStream = spriteData.css.pipe(gulp.dest(paths.styleDest));
//return merge(imgStream,cssStream).pipe(browserSync.reload({stream:true}));
// console.log(imgStream);
return merge(imgStream,cssStream);
})
我想使用webpack-spritesmith npm软件包将其转换为等效的webpack配置,以摆脱掉一团糟。我已经尝试了一些配置,但是由于不了解发生了什么,最终我陷入了混乱。如果可以的话,请帮忙。
谢谢。