Comments (14)
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.
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.
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.
@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.
That's what I'm about to do, too bad that the plugin does not clean its stuff itself.
from gulp-tinypng.
How can I delete a folder .gulp/tinypng with gulp?
from gulp-tinypng.
Take a look at the NPM rimraf module per example.
from gulp-tinypng.
@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.
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.
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]
the task 'del' does not remove '.gulp' folder. why the task 'tinypng' is finished before the actual end of its operations?
from gulp-tinypng.
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.
@pyrsmk here is my repo
https://github.com/Ferym26/GulpSass
I did not understand how it should work =(
from gulp-tinypng.
@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.
from gulp-tinypng.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google âĪïļ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-tinypng.