gulp-imagemin

Can I use gulp-imagemin with gulp-watch?

蓝咒 提交于 2021-02-08 02:10:35
问题 Can I use gulp-imagemin plugin with gulp-watch? So, I need to optimize images as soon as they are put into the folder. Here is a part of my gulpfile.js: var gulp = require('gulp'); var imagemin = require('gulp-imagemin'); var pngquant = require('imagemin-pngquant'); gulp.task('default', function() { gulp.watch('dist/images/**', function(event) { gulp.run('images'); }); }); // Image files gulp.task('images', function () { return gulp.src('src/images/*') .pipe(imagemin({ progressive: true,

gulp-imagemin: Couldn't load default plugin xxx

我怕爱的太早我们不能终老 提交于 2020-01-23 19:24:06
问题 the env: windows 7 node 6.9.5 I use the plugin like this npm. but I get an error. from some video, It's correct. It's relative to imagemin's version? // gulpfile.js var gulp = require('gulp'); var imagemin = require('gulp-imagemin'); var app = { srcPath: 'src/', devPath: 'build/', prdPath: 'dist/', //生产部署 } gulp.task('image', function() { gulp.src(app.srcPath + 'image/**/*') .pipe(gulp.dest(app.devPath + 'image')) .pipe(imagemin()) .pipe(gulp.dest(app.prdPath + 'image')) }) when I "gulp image

gulp-imagemin: Couldn't load default plugin xxx

你说的曾经没有我的故事 提交于 2020-01-23 19:23:10
问题 the env: windows 7 node 6.9.5 I use the plugin like this npm. but I get an error. from some video, It's correct. It's relative to imagemin's version? // gulpfile.js var gulp = require('gulp'); var imagemin = require('gulp-imagemin'); var app = { srcPath: 'src/', devPath: 'build/', prdPath: 'dist/', //生产部署 } gulp.task('image', function() { gulp.src(app.srcPath + 'image/**/*') .pipe(gulp.dest(app.devPath + 'image')) .pipe(imagemin()) .pipe(gulp.dest(app.prdPath + 'image')) }) when I "gulp image

Improve PNG optimization Gulp task

夙愿已清 提交于 2020-01-01 05:18:13
问题 This is source PNG with transparency: http://i.imgur.com/7m0zIBp.png (13.3kB) optimized using compresspng.com: http://i.imgur.com/DHUiLuO.png (5.4kB) optimized using tinypng.com: http://i.imgur.com/rEE2hzg.png (5.6kB) optimized with gulp-imagemin+imagemin-pngquant: http://i.imgur.com/OTqI6lK.png (6.6kB) As you can see online tools are better than Gulp. Is there a way to improve PNG optimization with Gulp? Just in case, here's my gulp task: gulp.task('images', function() { return gulp.src(

Installing gulp-imagemin on Windows creates well over 10,000 files

和自甴很熟 提交于 2019-12-24 04:13:07
问题 I have installed gulp-imagemin on my Windows 7 laptop using npm install --save-dev gulp-imagemin and after a lengthy process ended up with a folder with well over 10,000 files and some very deep folder structures. Has anyone else seen this? Is it likely to be correct or would I be right in suspecting an issue? 回答1: Yes it is correct. I've installed it too on my Windows machine and I saw the same thing as you describe here. The reason it has over 10,000 files and an even more lengthier

gulp-imagemin - how to disregard directory structures?

拟墨画扇 提交于 2019-12-12 06:05:38
问题 I'm using gulp-imagemin in it's basic form gulp.task('image', function() { return gulp.src('./images/*') .pipe(imagemin({ progressive: true, svgoPlugins: [{removeViewBox: false}], use: [pngquant()] })) .pipe(gulp.dest('./build/')); }); My images/ directory looks like images/ logo.png subfolder/ image.png I would like them to output as such: build/ logo.png image.png But they are retaining their folder structure. How can this be achieved? 回答1: I was able to achieve this with gulp-flatten by

Images not found when doing a production build with JHipster

自古美人都是妖i 提交于 2019-12-07 13:04:52
问题 When I am trying to deploy my application in my prod the WAR do not have the images directory so i get my application deploy without any images. What could be the problem? 回答1: It looks like the cause of the problem is "gulp-imagemin", as a workaround remove this line: .pipe(imagemin({optimizationLevel: 5, progressive: true, interlaced: true})) from: gulpfile.js 回答2: Your images must be in src/main/webapp/content/images to get minified and copied by gulp to target/www/content/images and then

Images not found when doing a production build with JHipster

帅比萌擦擦* 提交于 2019-12-06 01:53:52
When I am trying to deploy my application in my prod the WAR do not have the images directory so i get my application deploy without any images. What could be the problem? It looks like the cause of the problem is "gulp-imagemin", as a workaround remove this line: .pipe(imagemin({optimizationLevel: 5, progressive: true, interlaced: true})) from: gulpfile.js Your images must be in src/main/webapp/content/images to get minified and copied by gulp to target/www/content/images and then be copied at the root of you war in content/images by maven or gradle. If gulp-imagemin says it minified 0 images

Why don't newly added files trigger my gulp-watch task?

霸气de小男生 提交于 2019-11-30 19:08:54
I have a gulp task which uses gulp-imagemin to compress images. When I add new files to this directory I'd like for this task to compress them as well. I read that gulp.watch doesn't trigger on new files and that I should try gulp-watch so I used it like so; gulp.task('images', function() { watch({glob: './source/images/*'}, function (files) { return files .pipe(plumber()) .pipe(imagemin({ progressive: true, interlaced: true })) .pipe(gulp.dest('./www')); }); }); This works the same as gulp.watch on the first run, but when I add a new image to the directory nothing happens. If I overwrite an

Why don't newly added files trigger my gulp-watch task?

不打扰是莪最后的温柔 提交于 2019-11-30 03:49:06
问题 I have a gulp task which uses gulp-imagemin to compress images. When I add new files to this directory I'd like for this task to compress them as well. I read that gulp.watch doesn't trigger on new files and that I should try gulp-watch so I used it like so; gulp.task('images', function() { watch({glob: './source/images/*'}, function (files) { return files .pipe(plumber()) .pipe(imagemin({ progressive: true, interlaced: true })) .pipe(gulp.dest('./www')); }); }); This works the same as gulp