Skip to content

Instantly share code, notes, and snippets.

@mikestreety
Last active August 29, 2015 14:11
Show Gist options
  • Save mikestreety/14e3a90032acd9cf06a1 to your computer and use it in GitHub Desktop.
Save mikestreety/14e3a90032acd9cf06a1 to your computer and use it in GitHub Desktop.
I got 99 gulp problems but a sprite ain't one
/*
This is the folder structure:
gulpfile.js
build/
bp/
sass/
sprite/
img/
at/
sass/
sprite/
img/
prod/
assets/
bp/
css/
img/
at/
css/
img/
The sass currenty compiles from build/bp/sass to prod/assets/bp/css but below is
a sprite task that needs a proper destination path to work (e.g. build/bp/img
instead of build/** /img).
What it needs to do is look at the sprite folders, it then needs to generate and
put it in the img folder in the build folder (so take the files from
build/bp/sprite and put it in build/bp/img [or at depending on folder])
*/
gulp.task('svgSprite', function () {
return gulp.src('build/**/sprite/*')
.pipe(plugins.imagemin())
/* when i do a debug on this, i can get the folder it comes from, i just need to
replace ** on the src for it, but can't work out how */
.pipe(plugins.svgSprites({
cssFile: paths.sprite.css,
preview: false,
layout: 'diagonal',
padding: 5,
svg: {
sprite: paths.sprite.svg
},
templates: {
css: require("fs").readFileSync(paths.templates.src + 'sprite-template.scss', "utf-8")
}
}))
.pipe(gulp.dest(basePaths.src))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment