Git Product home page Git Product logo

netlify-plugin-image-optim's Introduction

netlify-plugin-image-optim

Optimize images as part of your Netlify build process. Optimizes PNG, JPEG, GIF and SVG file formats.

Install

You can install this plugin in the Netlify UI from this direct in-app installation link or from the Plugins directory.

To use file-based installation, add the following lines to your netlify.toml file:

[[plugins]]
package = "netlify-plugin-image-optim"

Note: The [[plugins]] line is required for each plugin, even if you have other plugins in your netlify.toml file already.

To complete file-based installation, from your project's base directory, use npm, yarn, or any other Node.js package manager to add this plugin to devDependencies in package.json.

npm install -D netlify-plugin-image-optim

netlify-plugin-image-optim's People

Contributors

aliblackwell avatar chrisdwheatley avatar dependabot[bot] avatar ehmicky avatar neverendingqs avatar rstavchansky avatar verythorough avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

netlify-plugin-image-optim's Issues

`Cannot create property 'message' on string 'Error in parsing SVG: Unbound namespace prefix: "xlink"`

The following error is happening in some builds:

Cannot create property 'message' on string 'Error in parsing SVG: Unbound namespace prefix: "xlink"
Line: 0
Column: 456
Char: >' 
    /opt/buildhome/.netlify-build-plugins/node_modules/imagemin-keep-folder/index.js:48:16 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:29:30 async onPostBuild
    src/plugins/child/run.js:18:3 async Object.run
    src/plugins/child/main.js:38:38 async handleEvent
    src/plugins/ipc.js:97:9 async process.<anonymous>

The build's repository is here.
Unfortunately, the build logs do not show any additional information.
Do you know what the problem might be?

Ability to set optimization ratio

Right now, it optimizes images too much, they become unenjoyable. It would be great to be able to control how much we want to optimize them.

Add incremental logs

Many users are canceling builds in the middle of this plugin due to the time taken by image minification.

One way to fix this could be to provide some type of incremental logs such as:

  • A progress bar
  • Or printing each file path, one by one, as they get minified

What do you think?

Add caching

Image processing can be quite slow.

It would be great if the minified images could be cached, so minification does not happen on the next build if the image has not changed.

For example:

  • {publishDir}/image.png is found
  • It is minified to {publishDir}/image-{hash}.png, where hash is the file's content hash
  • cache.save('{publishDir}/image-{hash}.png') is called (see cache utility documentation here)
  • on the next run, cache.restore('{publishDir}/image-{hash}.png') is called. If it returns true, that file does not need to be minified again
  • {publishDir}/image-{hash}.png is finally moved to {publishDir}/image.png

What do you think?

`ENOSPC` error

An ENOSPC error is thrown in some builds, indicating a file memory problem:

Error in file: storybook/assets/svg/check-sm.svg
ENOSPC: no space left on device, write 

The repository is private. Unfortunately the build logs do not show more information.

Do you know if big files might be accidentally created by this plugin, or whether this is more likely that this repository had big files to begin with? Thanks!

Error `Cannot read property 'each' of undefined`

The following error happens in some builds:

Error in file: build/static/media/animated_logo.52e0714e.svg

Cannot read property 'each' of undefined 
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:26:31 Object.enter
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:11:16 Object.<anonymous>
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:160:19 List.walkNode
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/common/List.js:158:12 List.each
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:106:29 Object.StyleSheet
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:163:37 walkNode
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:219:9 Object.walk
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:18:13 Object.flattenToSelectors
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/plugins/inlineStyles.js:82:47 Object.exports.fn
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/svgo/plugins.js:95:27 

Full build logs:

6:35:53 PM: Build ready to start
6:35:55 PM: build-image version: 9d79ad851d6eff3969322d6e5b1df3d597650c41
6:35:55 PM: build-image tag: v3.3.19
6:35:55 PM: buildbot version: 8e2e5a3a5212190d0490c1372e313994f9085345
6:35:55 PM: Fetching cached dependencies
6:35:55 PM: Starting to download cache of 254.3KB
6:35:55 PM: Finished downloading cache in 61.124077ms
6:35:55 PM: Starting to extract cache
6:35:55 PM: Failed to fetch cache, continuing with build
6:35:55 PM: Starting to prepare the repo for build
6:35:55 PM: No cached dependencies found. Cloning fresh repo
6:35:55 PM: git clone https://github.com/ritesh007sharma/PersonalWebsite-package.json
6:35:57 PM: Preparing Git Reference refs/heads/master
6:35:59 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'build/' in the Netlify UI
6:35:59 PM: Starting build script
6:35:59 PM: Installing dependencies
6:35:59 PM: Python version set to 2.7
6:36:00 PM: v12.18.0 is already installed.
6:36:01 PM: Now using node v12.18.0 (npm v6.14.4)
6:36:01 PM: Started restoring cached build plugins
6:36:01 PM: Finished restoring cached build plugins
6:36:01 PM: Attempting ruby version 2.7.1, read from environment
6:36:02 PM: Using ruby version 2.7.1
6:36:02 PM: Using PHP version 5.6
6:36:02 PM: 5.2 is already installed.
6:36:02 PM: Using Swift version 5.2
6:36:02 PM: Started restoring cached node modules
6:36:02 PM: Finished restoring cached node modules
6:36:02 PM: Installing NPM modules using NPM version 6.14.4
6:36:35 PM: > [email protected] install /opt/build/repo/node_modules/baseui
6:36:35 PM: > node -e "console.log('If you are using Webpack, please make sure to update to version ^4.32.0, as this Base Web version depends on a webpack fix delivered in that version. If you are using Fusion.js make sure to upgrade fusion-cli to ^2.4.2 as it has the Webpack upgrade.')"
6:36:35 PM: If you are using Webpack, please make sure to update to version ^4.32.0, as this Base Web version depends on a webpack fix delivered in that version. If you are using Fusion.js make sure to upgrade fusion-cli to ^2.4.2 as it has the Webpack upgrade.
6:36:35 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js
6:36:35 PM: > node -e "try{require('./postinstall')}catch(e){}"
6:36:35 PM: > [email protected] postinstall /opt/build/repo/node_modules/react-app-polyfill/node_modules/core-js
6:36:35 PM: > node -e "try{require('./postinstall')}catch(e){}"
6:36:37 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
6:36:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:36:37 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
6:36:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:36:37 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/chokidar/node_modules/fsevents):
6:36:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:36:37 PM: added 1655 packages from 850 contributors and audited 1790 packages in 34.149s
6:36:39 PM: 45 packages are looking for funding
6:36:39 PM:   run `npm fund` for details
6:36:39 PM: found 4 vulnerabilities (1 low, 2 moderate, 1 high)
6:36:39 PM:   run `npm audit fix` to fix them, or `npm audit` for details
6:36:39 PM: NPM modules installed
6:36:39 PM: Started restoring cached go cache
6:36:39 PM: Finished restoring cached go cache
6:36:39 PM: go version go1.14.4 linux/amd64
6:36:39 PM: go version go1.14.4 linux/amd64
6:36:39 PM: Installing missing commands
6:36:39 PM: Verify run directory
6:36:40 PM: ​
6:36:40 PM: ┌─────────────────────────────┐
6:36:40 PM: │        Netlify Build        │
6:36:40 PM: └─────────────────────────────┘
6:36:40 PM: ​
6:36:40 PM: ❯ Version
6:36:40 PM:   @netlify/build 2.0.20
6:36:40 PM: ​
6:36:40 PM: ❯ Flags
6:36:40 PM:   deployId: 5efb69e9d6c52ea901143813
6:36:40 PM:   mode: buildbot
6:36:40 PM: ​
6:36:40 PM: ❯ Current directory
6:36:40 PM:   /opt/build/repo
6:36:40 PM: ​
6:36:40 PM: ❯ Config file
6:36:40 PM:   No config file was defined: using default values.
6:36:40 PM: ​
6:36:40 PM: ❯ Context
6:36:40 PM:   production
6:36:40 PM: ​
6:36:40 PM: ❯ Loading plugins
6:36:40 PM:    - [email protected] from Netlify app
6:36:40 PM:    - @netlify/[email protected] from Netlify app
6:36:40 PM:    - [email protected] from Netlify app
6:36:41 PM: ​
6:36:41 PM: ┌────────────────────────────────────────────────────────┐
6:36:41 PM: │ 1. onPreBuild command from netlify-plugin-gatsby-cache │
6:36:41 PM: └────────────────────────────────────────────────────────┘
6:36:41 PM: ​
6:36:41 PM: No Gatsby cache found. Building fresh.
6:36:41 PM: ​
6:36:41 PM: (netlify-plugin-gatsby-cache onPreBuild completed in 251ms)
6:36:41 PM: ​
6:36:41 PM: ┌────────────────────────────────┐
6:36:41 PM: │ 2. Build command from settings │
6:36:41 PM: └────────────────────────────────┘
6:36:41 PM: ​
6:36:41 PM: $ npm run build
6:36:42 PM: > [email protected] build /opt/build/repo
6:36:42 PM: > react-scripts build
6:36:43 PM: Creating an optimized production build...
6:37:12 PM: Compiled successfully.
6:37:12 PM: 
6:37:12 PM: File sizes after gzip:
6:37:12 PM:   167.93 KB  build/static/js/2.6f967fcf.chunk.js
6:37:12 PM:   45.24 KB   build/static/js/main.c6e227c0.chunk.js
6:37:12 PM:   16.45 KB   build/static/css/main.a639f00b.chunk.css
6:37:12 PM:   785 B      build/static/js/runtime-main.0e64cde6.js
6:37:12 PM: The project was built assuming it is hosted at https://ritesh007sharma.github.io.
6:37:12 PM: You can control this with the homepage field in your package.json.
6:37:12 PM: The build folder is ready to be deployed.
6:37:12 PM: You may serve it with a static server:
6:37:12 PM:   npm install -g serve
6:37:12 PM:   serve -s build
6:37:12 PM: Find out more about deployment here:
6:37:12 PM:   https://bit.ly/CRA-deploy
6:37:12 PM: ​
6:37:12 PM: (build.command completed in 30.5s)
6:37:12 PM: ​
6:37:12 PM: ┌─────────────────────────────────────────────────────────┐
6:37:12 PM: │ 3. onPostBuild command from netlify-plugin-gatsby-cache │
6:37:12 PM: └─────────────────────────────────────────────────────────┘
6:37:12 PM: ​
6:37:12 PM: Stored the Gatsby cache to speed up future builds.
6:37:12 PM: ​
6:37:12 PM: (netlify-plugin-gatsby-cache onPostBuild completed in 108ms)
6:37:12 PM: ​
6:37:12 PM: ┌─────────────────────────────────────────────────────┐
6:37:12 PM: │ 4. onPostBuild command from @netlify/plugin-sitemap │
6:37:12 PM: └─────────────────────────────────────────────────────┘
6:37:12 PM: ​
6:37:12 PM: Creating sitemap from files...
6:37:12 PM: Sitemap Built! sitemap.xml
6:37:12 PM: ​
6:37:12 PM: (@netlify/plugin-sitemap onPostBuild completed in 40ms)
6:37:12 PM: ​
6:37:12 PM: ┌────────────────────────────────────────────────────────┐
6:37:12 PM: │ 5. onPostBuild command from netlify-plugin-image-optim │
6:37:12 PM: └────────────────────────────────────────────────────────┘
6:37:12 PM: ​
6:37:14 PM: ​
6:37:14 PM: ┌────────────────────────────────────────────────────┐
6:37:14 PM: │ Plugin "netlify-plugin-image-optim" internal error │
6:37:14 PM: └────────────────────────────────────────────────────┘
6:37:14 PM: ​
6:37:14 PM:   Error message
6:37:14 PM:   TypeError: Error in file: build/static/media/animated_logo.52e0714e.svg
6:37:14 PM: ​
6:37:14 PM:   Cannot read property 'each' of undefined
6:37:14 PM: ​
6:37:14 PM:   Plugin details
6:37:14 PM:   Package:        netlify-plugin-image-optim
6:37:14 PM:   Version:        0.3.0
6:37:14 PM:   Repository:     git+https://github.com/chrisdwheatley/netlify-plugin-image-optim.git
6:37:14 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-image-optim
6:37:14 PM:   Report issues:  https://github.com/chrisdwheatley/netlify-plugin-image-optim/issues
6:37:14 PM: ​
6:37:14 PM:   Error location
6:37:14 PM:   In "onPostBuild" event in "netlify-plugin-image-optim" from Netlify app
6:37:14 PM:       at Object.enter (/opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:26:31)
6:37:14 PM:       at Object.<anonymous> (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:11:16)
6:37:14 PM:       at List.walkNode (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:160:19)
6:37:14 PM:       at List.each (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/common/List.js:158:12)
6:37:14 PM:       at Object.StyleSheet (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:106:29)
6:37:14 PM:       at walkNode (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:163:37)
6:37:14 PM:       at Object.walk (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:219:9)
6:37:14 PM:       at Object.flattenToSelectors (/opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:18:13)
6:37:14 PM:       at Object.exports.fn (/opt/buildhome/.netlify-build-plugins/node_modules/svgo/plugins/inlineStyles.js:82:47)
6:37:14 PM:       at /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/svgo/plugins.js:95:27
6:37:14 PM: ​
6:37:14 PM:   Resolved config
6:37:14 PM:   build:
6:37:14 PM:     command: npm run build
6:37:14 PM:     publish: /opt/build/repo/build
6:37:14 PM:   plugins:
6:37:14 PM:     - inputs: {}
6:37:14 PM:       origin: ui
6:37:14 PM:       package: netlify-plugin-gatsby-cache
6:37:14 PM:     - inputs: {}
6:37:14 PM:       origin: ui
6:37:14 PM:       package: '@netlify/plugin-sitemap'
6:37:14 PM:     - inputs: {}
6:37:14 PM:       origin: ui
6:37:14 PM:       package: netlify-plugin-image-optim
6:37:14 PM: Caching artifacts
6:37:14 PM: Started saving node modules
6:37:14 PM: Finished saving node modules
6:37:14 PM: Started saving build plugins
6:37:14 PM: Finished saving build plugins
6:37:14 PM: Started saving pip cache
6:37:14 PM: Finished saving pip cache
6:37:14 PM: Started saving emacs cask dependencies
6:37:14 PM: Finished saving emacs cask dependencies
6:37:14 PM: Started saving maven dependencies
6:37:14 PM: Finished saving maven dependencies
6:37:14 PM: Started saving boot dependencies
6:37:14 PM: Finished saving boot dependencies
6:37:14 PM: Started saving go dependencies
6:37:14 PM: Finished saving go dependencies
6:37:17 PM: Error running command: Build script returned non-zero exit code: 1
6:37:17 PM: Failing build: Failed to build site
6:37:17 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
6:37:17 PM: Finished processing build request in 1m22.116204795s

The repository is private.
Do you know what the problem might be?

Plugin is not working with jpg/jpegs

I have noticed this now on two sites and it's not because I've achieved all the reduction I could have locally. It doesn't work with big images:

Screenshot_2020-07-21 Deploy details ecstatic-dijkstra-8ac4ed

I dug into it and it looks as though the imagemin JPEG plugin isn't being loaded. I have created a pull request that should fix this: #24

Deploy failed due to an error in netlify-plugin-image-optim plugin.

Hello I tried to install image optim on Hugo v 0.69.2 and I tried to deploy it I got the error bellow also I tried to install it manually then also I got the same error here is my repo mistrysiddh

Plugin "netlify-plugin-image-optim" internal error

Error: Error in file: public/favicon.png

spawn /opt/build/repo/node_modules/optipng-bin/vendor/optipng ENOENT

In "onPostBuild" event in "netlify-plugin-image-optim" from netlify.toml and package.json at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21)

Error properties: { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn /opt/build/repo/node_modules/optipng-bin/vendor/optipng', path: '/opt/build/repo/node_modules/optipng-bin/vendor/optipng', spawnargs: [ '-strip', 'all', '-clobber', '-o', 3, '-out', '/tmp/ab939e58-8d09-40cb-a20a-6a08cf8924b8', '-fix', '/tmp/e7532af3-315b-437b-bd41-3079030a0859' ], killed: false, stdout: '', stderr: '', failed: true, signal: null, cmd: '/opt/build/repo/node_modules/optipng-bin/vendor/optipng -strip all -clobber -o 3 -out /tmp/ab939e58-8d09-40cb-a20a-6a08cf8924b8 -fix /tmp/e7532af3-315b-437b-bd41-3079030a0859', timedOut: false }

Deploy log

8:31:57 PM: Build ready to start
8:31:59 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
8:31:59 PM: build-image tag: v3.6.0
8:31:59 PM: buildbot version: 7d7f8cd4cc19a5205bae0ea8df58feec103fed05
8:31:59 PM: Building without cache
8:31:59 PM: Starting to prepare the repo for build
8:31:59 PM: No cached dependencies found. Cloning fresh repo
8:31:59 PM: git clone https://github.com/mrfoxie/mistrysiddh
8:32:03 PM: Preparing Git Reference refs/heads/master
8:32:06 PM: Starting build script
8:32:06 PM: Installing dependencies
8:32:06 PM: Python version set to 2.7
8:32:08 PM: v12.18.0 is already installed.
8:32:08 PM: Now using node v12.18.0 (npm v6.14.4)
8:32:08 PM: Started restoring cached build plugins
8:32:08 PM: Finished restoring cached build plugins
8:32:08 PM: Attempting ruby version 2.7.1, read from environment
8:32:10 PM: Using ruby version 2.7.1
8:32:10 PM: Using PHP version 5.6
8:32:10 PM: Installing Hugo 0.69.2
8:32:12 PM: Hugo Static Site Generator v0.69.2-EC9DCF30/extended linux/amd64 BuildDate: 2020-04-24T07:57:53Z
8:32:12 PM: Started restoring cached go cache
8:32:12 PM: Finished restoring cached go cache
8:32:12 PM: go version go1.14.4 linux/amd64
8:32:12 PM: go version go1.14.4 linux/amd64
8:32:12 PM: Installing missing commands
8:32:12 PM: Verify run directory
8:32:13 PM: ​
8:32:13 PM: ────────────────────────────────────────────────────────────────
8:32:13 PM:   Netlify Build                                                 
8:32:13 PM: ────────────────────────────────────────────────────────────────
8:32:13 PM: ​
8:32:13 PM: ❯ Version
8:32:13 PM:   @netlify/build 8.0.5
8:32:13 PM: ​
8:32:13 PM: ❯ Flags
8:32:13 PM:   deployId: 6005a2e5ab6d7263c6aa77da
8:32:13 PM:   mode: buildbot
8:32:14 PM: ​
8:32:14 PM: ❯ Current directory
8:32:14 PM:   /opt/build/repo
8:32:14 PM: ​
8:32:14 PM: ❯ Config file
8:32:14 PM:   /opt/build/repo/netlify.toml
8:32:14 PM: ​
8:32:14 PM: ❯ Context
8:32:14 PM:   production
8:32:14 PM: ​
8:32:14 PM: ❯ Installing plugins
8:32:14 PM:    - @netlify/[email protected]
8:32:14 PM:    - [email protected]
8:32:17 PM: ​
8:32:17 PM: ❯ Loading plugins
8:32:17 PM:    - @netlify/[email protected] from Netlify app
8:32:17 PM:    - [email protected] from Netlify app
8:32:17 PM:    - [email protected] from netlify.toml and package.json
8:32:19 PM: ​
8:32:19 PM: ────────────────────────────────────────────────────────────────
8:32:19 PM:   1. Build command from Netlify app                             
8:32:19 PM: ────────────────────────────────────────────────────────────────
8:32:19 PM: ​
8:32:19 PM: $ hugo
8:32:26 PM: Building sites …
8:32:26 PM:                    | EN  | KO
8:32:26 PM: -------------------+-----+------
8:32:26 PM:   Pages            | 214 |  16
8:32:26 PM:   Paginator pages  |   3 |   0
8:32:26 PM:   Non-page files   |   0 |   0
8:32:26 PM:   Static files     | 192 | 192
8:32:26 PM:   Processed images |   0 |   0
8:32:26 PM:   Aliases          |  55 |   1
8:32:26 PM:   Sitemaps         |   2 |   1
8:32:26 PM:   Cleaned          |   0 |   0
8:32:26 PM: Total in 6416 ms
8:32:26 PM: ​
8:32:26 PM: (build.command completed in 6.5s)
8:32:26 PM: ​
8:32:26 PM: ────────────────────────────────────────────────────────────────
8:32:26 PM:   2. onPostBuild command from @netlify/plugin-sitemap           
8:32:26 PM: ────────────────────────────────────────────────────────────────
8:32:26 PM: ​
8:32:26 PM: Creating sitemap from files...
8:32:26 PM: Sitemap Built! sitemap.xml
8:32:26 PM: ​
8:32:26 PM: (@netlify/plugin-sitemap onPostBuild completed in 128ms)
8:32:26 PM: ​
8:32:26 PM: ────────────────────────────────────────────────────────────────
8:32:26 PM:   3. onPostBuild command from netlify-plugin-image-optim        
8:32:26 PM: ────────────────────────────────────────────────────────────────
8:32:26 PM: ​
8:32:28 PM: ​
8:32:28 PM: ────────────────────────────────────────────────────────────────
8:32:28 PM:   Plugin "netlify-plugin-image-optim" internal error            
8:32:28 PM: ────────────────────────────────────────────────────────────────
8:32:28 PM: ​
8:32:28 PM:   Error message
8:32:28 PM:   Error: Error in file: public/favicon.png
8:32:28 PM: ​
8:32:28 PM:   spawn /opt/build/repo/node_modules/optipng-bin/vendor/optipng ENOENT
8:32:28 PM: ​
8:32:28 PM:   Plugin details
8:32:28 PM:   Package:        netlify-plugin-image-optim
8:32:28 PM:   Version:        0.4.0
8:32:28 PM:   Repository:     git+https://github.com/chrisdwheatley/netlify-plugin-image-optim.git
8:32:28 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-image-optim
8:32:28 PM:   Report issues:  https://github.com/chrisdwheatley/netlify-plugin-image-optim/issues
8:32:28 PM: ​
8:32:28 PM:   Error location
8:32:28 PM:   In "onPostBuild" event in "netlify-plugin-image-optim" from netlify.toml and package.json
8:32:28 PM:       at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
8:32:28 PM:       at onErrorNT (internal/child_process.js:469:16)
8:32:28 PM:       at processTicksAndRejections (internal/process/task_queues.js:84:21)
8:32:28 PM: ​
8:32:28 PM:   Error properties
8:32:28 PM:   {
8:32:28 PM:     errno: 'ENOENT',
8:32:28 PM:     code: 'ENOENT',
8:32:28 PM:     syscall: 'spawn /opt/build/repo/node_modules/optipng-bin/vendor/optipng',
8:32:28 PM:     path: '/opt/build/repo/node_modules/optipng-bin/vendor/optipng',
8:32:28 PM:     spawnargs: [
8:32:28 PM:       '-strip',
8:32:28 PM:       'all',
8:32:28 PM:       '-clobber',
8:32:28 PM:       '-o',
8:32:28 PM:       3,
8:32:28 PM:       '-out',
8:32:28 PM:       '/tmp/ab939e58-8d09-40cb-a20a-6a08cf8924b8',
8:32:28 PM:       '-fix',
8:32:28 PM:       '/tmp/e7532af3-315b-437b-bd41-3079030a0859'
8:32:28 PM:     ],
8:32:28 PM:     killed: false,
8:32:28 PM:     stdout: '',
8:32:28 PM:     stderr: '',
8:32:28 PM:     failed: true,
8:32:28 PM:     signal: null,
8:32:28 PM:     cmd: '/opt/build/repo/node_modules/optipng-bin/vendor/optipng -strip all -clobber -o 3 -out /tmp/ab939e58-8d09-40cb-a20a-6a08cf8924b8 -fix /tmp/e7532af3-315b-437b-bd41-3079030a0859',
8:32:28 PM:     timedOut: false
8:32:28 PM:   }
8:32:28 PM: ​
8:32:28 PM:   Resolved config
8:32:28 PM:   build:
8:32:28 PM:     command: hugo
8:32:28 PM:     commandOrigin: ui
8:32:28 PM:     environment:
8:32:28 PM:       - HUGO_VERSION
8:32:28 PM:     publish: /opt/build/repo/public
8:32:28 PM:   plugins:
8:32:28 PM:     - inputs: {}
8:32:28 PM:       origin: ui
8:32:28 PM:       package: '@netlify/plugin-sitemap'
8:32:28 PM:     - inputs: {}
8:32:28 PM:       origin: ui
8:32:28 PM:       package: netlify-plugin-submit-sitemap
8:32:28 PM:     - inputs: {}
8:32:28 PM:       origin: config
8:32:28 PM:       package: netlify-plugin-image-optim
8:32:28 PM: Caching artifacts
8:32:28 PM: Started saving node modules
8:32:28 PM: Finished saving node modules
8:32:28 PM: Started saving build plugins
8:32:28 PM: Finished saving build plugins
8:32:28 PM: Started saving pip cache
8:32:28 PM: Finished saving pip cache
8:32:28 PM: Started saving emacs cask dependencies
8:32:28 PM: Finished saving emacs cask dependencies
8:32:28 PM: Started saving maven dependencies
8:32:28 PM: Finished saving maven dependencies
8:32:28 PM: Started saving boot dependencies
8:32:28 PM: Finished saving boot dependencies
8:32:28 PM: Started saving rust rustup cache
8:32:28 PM: Finished saving rust rustup cache
8:32:28 PM: Started saving rust cargo bin cache
8:32:28 PM: Finished saving rust cargo bin cache
8:32:28 PM: Started saving go dependencies
8:32:28 PM: Finished saving go dependencies
8:32:31 PM: Build failed due to a plugin error: Build script returned non-zero exit code: 3
8:32:31 PM: Failing build: Failed to build site
8:32:31 PM: Failed during stage 'building site': Build script returned non-zero exit code: 3
8:32:31 PM: Finished processing build request in 32.456450735s

`ENOTDIR` error

The following error is happening in some builds:

7:56:26 PM: Build ready to start
7:56:28 PM: build-image version: 30f629161c0736b1a3ecd8b418e5eeffab5c0faf
7:56:28 PM: build-image tag: v3.3.14
7:56:28 PM: buildbot version: a383ed3390159974f55f285b04457b44cb49efb0
7:56:28 PM: Fetching cached dependencies
7:56:28 PM: Starting to download cache of 254.3KB
7:56:28 PM: Finished downloading cache in 65.817082ms
7:56:28 PM: Starting to extract cache
7:56:28 PM: Failed to fetch cache, continuing with build
7:56:28 PM: Starting to prepare the repo for build
7:56:29 PM: No cached dependencies found. Cloning fresh repo
7:56:29 PM: git clone https://github.com/r-token/ryantoken.com
7:56:31 PM: Preparing Git Reference refs/heads/master
7:56:33 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'Output/index.html' versus 'index.html' in the Netlify UI
7:56:33 PM: Starting build script
7:56:33 PM: Installing dependencies
7:56:34 PM: Downloading and installing node v10.21.0...
7:56:34 PM: Downloading https://nodejs.org/dist/v10.21.0/node-v10.21.0-linux-x64.tar.xz...
7:56:35 PM: Computing checksum with sha256sum
7:56:35 PM: Checksums matched!
7:56:37 PM: Now using node v10.21.0 (npm v6.14.4)
7:56:37 PM: Started restoring cached build plugins
7:56:37 PM: Finished restoring cached build plugins
7:56:37 PM: Attempting ruby version 2.6.2, read from environment
7:56:39 PM: Using ruby version 2.6.2
7:56:39 PM: Using PHP version 5.6
7:56:39 PM: 5.2 is already installed.
7:56:39 PM: Using Swift version 5.2
7:56:39 PM: Started restoring cached go cache
7:56:39 PM: Finished restoring cached go cache
7:56:39 PM: go version go1.12 linux/amd64
7:56:39 PM: go version go1.12 linux/amd64
7:56:39 PM: Installing missing commands
7:56:39 PM: Verify run directory
7:56:40 PM: ​
7:56:40 PM: ┌─────────────────────────────┐
7:56:40 PM: │        Netlify Build        │
7:56:40 PM: └─────────────────────────────┘
7:56:41 PM: ​
7:56:41 PM: ❯ Version
7:56:41 PM:   @netlify/build 1.0.16
7:56:41 PM: ​
7:56:41 PM: ❯ Flags
7:56:41 PM:   mode: buildbot
7:56:41 PM: ​
7:56:41 PM: ❯ Current directory
7:56:41 PM:   /opt/build/repo/Output
7:56:41 PM: ​
7:56:41 PM: ❯ Config file
7:56:41 PM:   No config file was defined: using default values.
7:56:41 PM: ​
7:56:41 PM: ❯ Context
7:56:41 PM:   production
7:56:41 PM: ​
7:56:41 PM: ❯ Loading plugins
7:56:41 PM:    - [email protected] from Netlify app
7:56:42 PM: ​
7:56:42 PM: ┌────────────────────────────────────────────────────────┐
7:56:42 PM: │ 1. onPostBuild command from netlify-plugin-image-optim │
7:56:42 PM: └────────────────────────────────────────────────────────┘
7:56:42 PM: ​
7:56:42 PM: ​
7:56:42 PM: ┌────────────────────────────────────────────────────┐
7:56:42 PM: │ Plugin "netlify-plugin-image-optim" internal error │
7:56:42 PM: └────────────────────────────────────────────────────┘
7:56:42 PM: ​
7:56:42 PM:   Error message
7:56:42 PM:   Error: ENOTDIR: not a directory, stat '/opt/build/repo/Output/index.html/**/*.{gif,jpg,jpeg,png,svg}'
7:56:42 PM: ​
7:56:42 PM:   Plugin details
7:56:42 PM:   Package:        netlify-plugin-image-optim
7:56:42 PM:   Version:        0.3.0
7:56:42 PM:   Repository:     git+https://github.com/chrisdwheatley/netlify-plugin-image-optim.git
7:56:42 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-image-optim
7:56:42 PM:   Report issues:  https://github.com/chrisdwheatley/netlify-plugin-image-optim/issues
7:56:42 PM: ​
7:56:42 PM:   Error location
7:56:42 PM:   In "onPostBuild" event in "netlify-plugin-image-optim" from Netlify app
7:56:42 PM: ​
7:56:42 PM:   Error properties
7:56:42 PM:   {
7:56:42 PM:     errno: -20,
7:56:42 PM:     code: 'ENOTDIR',
7:56:42 PM:     syscall: 'stat',
7:56:42 PM:     path: '/opt/build/repo/Output/index.html/**/*.{gif,jpg,jpeg,png,svg}'
7:56:42 PM:   }
7:56:42 PM: ​
7:56:42 PM:   Resolved config
7:56:42 PM:   build:
7:56:42 PM:     base: /opt/build/repo/Output
7:56:42 PM:     publish: /opt/build/repo/Output/index.html
7:56:42 PM:   plugins:
7:56:42 PM:     - inputs: {}
7:56:42 PM:       origin: ui
7:56:42 PM:       package: netlify-plugin-image-optim
7:56:42 PM: Caching artifacts
7:56:42 PM: Started saving build plugins
7:56:42 PM: Finished saving build plugins
7:56:42 PM: Started saving pip cache
7:56:42 PM: Finished saving pip cache
7:56:42 PM: Started saving emacs cask dependencies
7:56:42 PM: Finished saving emacs cask dependencies
7:56:42 PM: Started saving maven dependencies
7:56:42 PM: Finished saving maven dependencies
7:56:42 PM: Started saving boot dependencies
7:56:42 PM: Finished saving boot dependencies
7:56:42 PM: Started saving go dependencies
7:56:42 PM: Finished saving go dependencies
7:56:45 PM: Error running command: Build script returned non-zero exit code: 1
7:56:45 PM: Failing build: Failed to build site
7:56:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
7:56:46 PM: Finished processing build request in 17.545908067s

The repository is this one.
Do you know what the error might be?

`background color not in colormap` error

The following error is happening in some builds.

Error in file: public/static/0fcc4b193c9b78671c8ba9d2fdeaf48c/canva_pro_logo.gif
gifsicle:/tmp/5429c4b3-0087-46ef-99d5-82b31b1f4f55: background color not in colormap 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:29:30 async onPostBuild
    src/plugins/child/run.js:18:3 async Object.run
    src/plugins/child/main.js:38:38 async handleEvent
    src/plugins/ipc.js:97:9 async process.<anonymous>

The repository is private. The builds logs are not providing additional information unfortunately.

It looks like this error might be a user error. If this is the case, it might be good to wrap the imagemin() with a try/catch block and use utils.build.failBuild(). This method ensures that uncaught exceptions are reported as user errors instead of plugin bugs. More information can be found here.

Add error handling to `imagemin`

imagemin can fail when images are invalid. For example:

Error in file: _site/images/dev-notes/louyang_give_random_options.gif

gifsicle:/tmp/dc6ecfb2-8c1d-42e0-885b-21156391edb5:#91: read error: missing 48918 pixels of image data
gifsicle:/tmp/dc6ecfb2-8c1d-42e0-885b-21156391edb5:#91: fatal error: too many missing pixels, giving up

This is currently being reported as a plugin error. try/catch and utils.build.failBuild() should be used instead to report this as a user error.

Plugin "netlify-plugin-image-optim" internal error

Plugin "netlify-plugin-image-optim" internal error

TypeError: Cannot set property 'post' of undefined

In "onPostBuild" event in "netlify-plugin-image-optim" from Netlify app
at /opt/build/repo/.netlify/plugins/node_modules/netlify-plugin-image-optim/index.js:38:26
at Array.map ()
at onPostBuild (/opt/build/repo/.netlify/plugins/node_modules/netlify-plugin-image-optim/index.js:34:22)
at async Object.run (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/run.js:20:3)
at async handleEvent (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/main.js:36:38)
at async process. (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/ipc.js:103:16)

branch filtering

I want my deploy previews to be fast. This plugin took 15 minutes to run. Can I configure it to only run on commits to a specific branch e.g. master?

`ENOENT` error

The following error is happening in some builds:

Error in file: _site/images/troy-logo-white_1072x1072.png 
ENOENT: no such file or directory, open '_site/images/troy-logo-white_1072x1072.png' 

The repository is here. The build logs do not show additional information unfortunately.
Do you know what the error might be?

`stats` is sometimes `undefined`

Some builds report the following error:

Cannot set property 'post' of undefined 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:37:26 
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-image-optim/index.js:33:22 onPostBuild
    src/plugins/child/run.js:18:3 async Object.run
    src/plugins/child/main.js:38:38 async handleEvent
    src/plugins/ipc.js:97:9 async process.<anonymous>

This seems to indicate that some file paths returned by imagemin() point to non-existing files. I am not quire sure how this might be happening.
The repository is here. The build logs are not showing additional information unfortunately.

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.