Giter Site home page Giter Site logo

error on svg about imagemin HOT 1 CLOSED

Stephan-Pe avatar Stephan-Pe commented on July 18, 2024
error on svg

from imagemin.

Comments (1)

Stephan-Pe avatar Stephan-Pe commented on July 18, 2024 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)

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.