Giter Site home page Giter Site logo

sudongyuer / easy-tinypng-cli Goto Github PK

View Code? Open in Web Editor NEW
67.0 1.0 8.0 7.04 MB

๐Ÿผ A cli can automatically compress images with tinypng.com

Home Page: https://www.npmjs.com/package/easy-tinypng-cli

License: MIT License

TypeScript 82.48% HTML 2.92% CSS 14.23% JavaScript 0.37%
compress compress-images images tiny tinypng-api tinypng-cli

easy-tinypng-cli's Introduction

easy-tinypng-cli

A cli can automatically compress images with tinypng.com.

NPM version

Why

When delevoping a website, we often need to compress images to reduce the network io cast.In normal way, we may need four steps to compress images:

  1. download images from the internet
  2. upload the image to tinypng.com
  3. download the compressed image from tinypng.com
  4. copy the compressd images into our workspace

The above steps are very time-consuming. So !!! this cli can automatically compress images in background process. It will watch the fileSystem changes to auto handle if there are any images that need to be compressed.

๐Ÿš€ Features

  • ๐Ÿ’พ Support configuration file
  • ๐Ÿ Multiple directory watching
  • โœจ Support HMR
  • ๐Ÿฆ‹ Auto detection nested directory images and compress them
  • ๐ŸŒ Background process will not block the main thread
  • ๐Ÿปโ€โ„๏ธ Compressed record logging to avoid repeated compression

vite-plugin-vue-inspector

Usage

Install

pnpm add -D easy-tinypng-cli

Config tiny.config.ts

  • APIKey (required) : the API key of tinypng.com, you can get it from tinypng.com

  • targetDir (required) : the top directory that you want to compress images

import { defineTinyConfig } from 'easy-tinypng-cli/utils'

export default defineTinyConfig({
  configs: [
    {
      targetDir: './src/images',
    },
  ],
  APIKey: 'xxxxxxxxx',
})

Add Script in package.json

{
  "scripts": {
    "optimizeImages": "tiny"
  }
}

or

{
  "scripts": {
    "optimizeImages": "tiny --once" //only compress once no watching files change
  }
}

Author

sudongyuer email:[email protected]

License

MIT License ยฉ 2021 SuDongYu

easy-tinypng-cli's People

Contributors

github-actions[bot] avatar sudongyuer 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  avatar  avatar  avatar

Watchers

 avatar

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.