Comments (1)
found solution:
got the following error when i wrapped the pipe into try catch block
node:internal/process/promises:288
triggerUncaughtException(err, true /_ fromPromise _/);
^
PluginError: Plugin name should be specified
at resolvePluginConfig (C:\Projects\gulp-ecma6\node_modules\svgo\lib\svgo\config.js:113:13)
at Array.map (<anonymous>)
at optimize (C:\Projects\gulp-ecma6\node_modules\svgo\lib\svgo.js:50:37)
at optimize (C:\Projects\gulp-ecma6\node_modules\svgo\lib\svgo-node.js:97:10)
at C:\Projects\gulp-ecma6\node_modules\imagemin-svgo\index.js:16:17
at file:///C:/Projects/gulp-ecma6/node_modules/p-pipe/index.js:10:25.......
so I took the options out of the plugins array like this
const isProd = process.env.NODE_ENV === "prod";
const { dest } = gulp;
const imgSource = "src/img/**/.";
async function imageMin() {
try {
return gulp.src([imgSource])
.pipe(gulpIf(isProd, imagemin([
gifsicle({ interlaced: true }),
mozjpeg({ quality: 75, progressive: true }),
optipng({ optimizationLevel: 5 }),
svgo({
removeViewBox: true,
cleanupIDs: false
})
])))
.pipe(dest("docs/img/"));
} catch (error) {
console.log(error);
}
}
export default imageMin;
now everything works like acspected
[14:44:22] Finished 'processJson' after 2.68 s
[14:44:23] asset main.js 2.42 KiB [emitted] [minimized] (name: main)
webpack 5.75.0 compiled successfully
[14:44:23] Finished 'processJS' after 3.9 s
[14:44:23] Finished 'default' after 3.92 s
[14:44:24] gulp-imagemin: Minified 17 images (saved 424 kB - 42.6%)
from imagemin.
Related Issues (20)
- destination path HOT 1
- Error: EMFILE: too many open files on W10
- gulp-imagemin: Could not load default plugin mozjpeg/optipng
- Not finding any files in my src directory HOT 1
- UnhandledPromiseRejectionWarning:/node_modules/imagemin/index.js:1 (function (exports, require, module, __filename, __dirname) { import {Buffer} from 'node:buffer';SyntaxError: Unexpected token {
- Question : Can we use this package in React-Native as well ? HOT 2
- Errors not thrown in 8.0.1
- Cannot read properties of undefined (reading 'buffer')
- file-type vulnerable to Infinite Loop via malformed MKV file HOT 2
- imagemin looping issue HOT 4
- Is it possible to convert a file coming from HTML input and upload to bucket without saving it to file system?
- No viable alternative to imagemin - applying for maintainer privileges HOT 9
- TypeError: imagemin.svgo is not a function HOT 2
- Destination path null HOT 1
- why not build commonjs module ? HOT 1
- imagemin not work (ERR_REQUIRE_ESM) HOT 5
- Imagemin not Optimazing images in Gupl v5
- when basic details as mentioned in gulp docs is ran for imagemin. Result is not showing how much its optimised for v9.0.0 HOT 1
- Webpack 5 usage with imagemin and imagemin-svgo for .svg and .gif emits errors: `Expected a 'string', got 'object'` HOT 3
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 imagemin.