Abdul Sadik Yalcin
Abdul Sadik Yalcin

Reputation: 1822

javascript - Gulp not copying images

After changing the gulp destination folder, my images are no longer being copied but everything else is... I get my notification but "images" folder is not created nor the images are copied... (I am a newbie with gulp so please forgive me if it's a stupid mistake :)

gulp.task('images', function() {
  return gulp.src('src/images/**/*')
    .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
    .pipe(gulp.dest('../viewer/images'))
    .pipe(notify({ message: 'Images optimised', onLast: true }));
});

Structure:

parent

  - viewer (destination folder)
    - js (copied)
    - css (copied)
    - fonts (copied)
    - index.html (copied)
    - maps (copied)

  - p-viewer
    - src
    - gulpfile.js

Upvotes: 0

Views: 355

Answers (1)

samanime
samanime

Reputation: 26615

I suspect your destination should probably be just viewer/images. The destination is relative to where the gulpfile is, not relative to your source.

My assumption has this as your folder structure:

- src
  - images
- viewer
  - images
- gulpfile.js

Your code has this as your folder structure:

- parent    
  - src
    - images
  - gulpfile.js
- viewer
  - images

which probably isn't what you intended.

If it is, I believe there is also a security thing in gulp that doesn't let you operate in folders that are higher than the gulp file (so you can't accidentally do something crazy to your system).

Upvotes: 1

Related Questions