Coder Social home page Coder Social logo

Wrong output folder about gulp-tinypng HOT 14 OPEN

creativeaura avatar creativeaura commented on June 7, 2024
Wrong output folder

from gulp-tinypng.

Comments (14)

creativeaura avatar creativeaura commented on June 7, 2024

The plugin temporally download the images to .gulp folder because it have to download the image for the tinypng server.

You can pipe them to any destination folder.

.pipe(gulp.dest('compressed_images')

from gulp-tinypng.

ericcholis avatar ericcholis commented on June 7, 2024

I noticed this as well. I've piped the images to a new folder, but the temporary files in .gulp are still present.

from gulp-tinypng.

creativeaura avatar creativeaura commented on June 7, 2024

Every time you run the task the images for removed. We can't empty the folder until its been copied to the destination folder in the next pipe step.

from gulp-tinypng.

lmartins avatar lmartins commented on June 7, 2024

@creativeaura Totally missed you comment here, until today when looking for a solution to this.
You're suggesting manually removing that .gulp folder after the images have been processed?

from gulp-tinypng.

pyrsmk avatar pyrsmk commented on June 7, 2024

That's what I'm about to do, too bad that the plugin does not clean its stuff itself.

from gulp-tinypng.

Ferym26 avatar Ferym26 commented on June 7, 2024

How can I delete a folder .gulp/tinypng with gulp?

from gulp-tinypng.

pyrsmk avatar pyrsmk commented on June 7, 2024

Take a look at the NPM rimraf module per example.

from gulp-tinypng.

Ferym26 avatar Ferym26 commented on June 7, 2024

@pyrsmk thx, but how to do it after tinypng task?
var rimraf = require('rimraf');
gulp.task('tinypng', function () {
gulp.src(['app/img//*.png', '!app/img/compressed//*.png'])
.pipe(tinypng('my api key'))
.pipe(gulp.dest('app/img/compressed/'))
.pipe(rimraf('.gulp'));
});
It does not work.

from gulp-tinypng.

pyrsmk avatar pyrsmk commented on June 7, 2024

Rimraf is not a gulp module. Search on NPM for a gulp module that remove directories, there are several ;) (note that you'll need to create another task to remove your directory as the files in your tinypng task are your images and not the .gulp/tinypng/ directory)

from gulp-tinypng.

Ferym26 avatar Ferym26 commented on June 7, 2024

If I do so:

// Compress PNG Task
gulp.task('compress', ['tinypng', 'del']);

gulp.task('tinypng', function () {
gulp.src(['app/img//*.png', '!app/img/compressed//*.png'])
.pipe(tinypng('my api key'))
.pipe(gulp.dest('app/img/compressed/'));
});

gulp.task('del', ['tinypng'], function (cb) {
rimraf('.gulp', cb);
});

then
$gulp compress
[13:31:39] Starting 'tinypng'...
[13:31:39] Finished 'tinypng' after 10 ms
[13:31:39] Starting 'del'...
[13:31:39] Finished 'del' after 8.84 ms
[13:31:39] Starting 'compress'...
[13:31:39] Finished 'compress' after 7 Ξs
[13:31:42] gulp-tingpng: [compressing] ✔ tumblr_muuig0890N1st5lhmo1_1280.png (done)

the task 'del' does not remove '.gulp' folder. why the task 'tinypng' is finished before the actual end of its operations?

from gulp-tinypng.

pyrsmk avatar pyrsmk commented on June 7, 2024

You're not using gulp as expected. Gulp tasks should return streams so tasks are knowing when subtasks have finished.

Furthermore, subtasks are executed all at once! So, when you're calling compress, gulp will execute tinypng and del subtasks in parallel.

First, remove your compress task. It's useless. Rename your del task in compress (to keep logic). And make your tinypng task return gulp.src. Now, when you're running gulp compress, gulp will call the compress task which will be waiting for tinypng to execute and then will run the compress code.

Please refer, to the gulp code to well understand how it's working ;)

from gulp-tinypng.

Ferym26 avatar Ferym26 commented on June 7, 2024

@pyrsmk here is my repo
https://github.com/Ferym26/GulpSass
I did not understand how it should work =(

from gulp-tinypng.

Ferym26 avatar Ferym26 commented on June 7, 2024

@pyrsmk helped to find a solution. there is
var tinypng = require('gulp-tinypng');
var rimraf = require('rimraf'); // delete folder
gulp.task('tinypng', function () {
return gulp.src(['app/img//*.png', '!app/img/compressed//*.png'])
.pipe(tinypng('lMaOo89RU3OngPRhsSAzAEjqqxPGe4rU'))
.pipe(gulp.dest('app/img/compressed/'));
});

gulp.task('compress', ['tinypng'], function (cb) {
rimraf('.gulp', cb);
});

from gulp-tinypng.

pyrsmk avatar pyrsmk commented on June 7, 2024

👍

from gulp-tinypng.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google âĪïļ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.