How to solve gulp image copy issue on build? -


problem - copied images end size 0 x 0 px.

in gulpfile.js copy images app directory dist directory, works well. here's simplified version of task:

gulp.task('html-deploy', function() {     return gulp.src([         'app/img/**/*',         'app/**/*.html'         ],         {             base: 'app'         }     )     .pipe(gulp.dest('dist')) }); 

my file structure looks this:

/app     index.html     /img         image1.png         image2.png 

everything copies on , nice, images don't display in browser, though filepaths correct.

the weird thing when locate images directly in finder (osx) can't view them there either, although filesizes , read/write values correct too.

this because copied images end being 0x0 px in size. why happening?

this kind of answer own question - @ least fixed problem.

instead of directly copying images copy them via gulp-imagemin, , voilĂ !

var gulp = require('gulp'); var imagemin = require('gulp-imagemin') var del = require('del')  // minify , copy new images dist     gulp.task('imagemin', ['clean'], function() {         return gulp.src('app/img/**/*')             .pipe(changed('dist/img'))             .pipe(imagemin())             .pipe(gulp.dest('dist/img'))     }) 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -