easy-tinypng-cli
Version:
A cli can be used to compress images with tinypng.com
92 lines • 4.62 kB
JSON
{
"name": "easy-tinypng-cli",
"type": "module",
"version": "0.4.1",
"description": "A cli can be used to compress images with tinypng.com",
"author": "sudongyuer",
"license": "MIT",
"funding": "https://github.com/sponsors/sudongyuer",
"homepage": "https://github.com/sudongyuer/easy-tinypng-cli#readme",
"repository": "https://github.com/sudongyuer/easy-tinypng-cli",
"bugs": "https://github.com/sudongyuer/easy-tinypng-cli/issues",
"keywords": [
"tinypng",
"image",
"compress",
"cli",
"tiny-cli"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.js"
},
"./utils": {
"types": "./dist/utils.d.ts",
"require": "./dist/utils.js",
"import": "./dist/utils.js"
}
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./dist/index.d.ts"
]
}
},
"bin": {
"tiny": "bin/optimize.js"
},
"files": [
"dist"
],
"dependencies": {
"chalk": "4.1.2",
"chokidar": "^3.5.3",
"commander": "^9.4.0",
"fast-glob": "^3.2.11",
"figlet": "^1.5.2",
"fs-extra": "^10.1.0",
"ora": "^6.1.2",
"tinify": "^1.6.1",
"unconfig": "^0.3.5"
},
"devDependencies": {
"@sudongyuer/eslint-config": "^0.1.3",
"@types/figlet": "^1.5.4",
"@types/fs-extra": "^9.0.13",
"@types/node": "^18.0.0",
"eslint": "^8.18.0",
"rimraf": "^3.0.2",
"tsx": "^3.6.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.4",
"vite": "^2.9.12",
"vitest": "^0.15.2"
},
"eslintConfig": {
"extends": [
"@sudongyuer"
]
},
"scripts": {
"dev": "unbuild --stub --declaration",
"build": "rimraf ./dist && tsc",
"test": "vitest",
"tsc": "rimraf ./dist && tsc --watch",
"version": "changeset version",
"changeset": "changeset add",
"release": "pnpm run build && pnpm run release:only",
"release:only": "changeset publish",
"typecheck": "tsc --noEmit",
"lint": "eslint . --cache",
"lint-fix": "eslint . --fix",
"try": "tsx src/index.ts"
},
"readme": "# easy-tinypng-cli\n\nA cli can automatically compress images with [tinypng.com.](https://tinypng.com/)\n\n[](https://www.npmjs.com/package/easy-tinypng-cli)\n\n\n<p align='center'>\n<img src='https://git.poker/sudongyuer/image-bed/blob/master/20220731/easy-tinypng-cli.png?raw=true' width='200'/>\n</p>\n\n## Why\n\nWhen 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: \n1. download images from the internet\n2. upload the image to [tinypng.com](https://tinypng.com/) \n3. download the compressed image from [tinypng.com](https://tinypng.com/) \n4. copy the compressd images into our workspace\n\nThe 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.\n\n## 🚀 Features\n\n- 💾 Support configuration file\n- 🍁 Multiple directory watching\n- ✨ Support HMR\n- 🦋 Auto detection nested directory images and compress them\n- 🌝 Background process will not block the main thread\n- 🐻❄️ Compressed record logging to avoid repeated compression\n\n<p align=\"center\">\n<img src=\"https://git.poker/sudongyuer/image-bed/blob/master/20220731/easy-tinypng-cli-preview.xkrdjpi00ao.gif?raw=true\" alt=\"vite-plugin-vue-inspector\">\n</p>\n\n## Usage\n\n### Install\n\n```ball\npnpm add -D easy-tinypng-cli\n```\n\n### Config `tiny.config.ts`\n\n- APIKey (required) : the API key of [tinypng.com](https://tinypng.com/), you can get it from [tinypng.com](https://tinypng.com/)\n\n- targetDir (required) : the top directory that you want to compress images\n\n\n```js\nimport { defineTinyConfig } from 'easy-tinypng-cli/utils'\n\nexport default defineTinyConfig({\n configs: [\n {\n targetDir: './src/images',\n },\n ],\n APIKey: 'xxxxxxxxx',\n})\n\n```\n### Add Script in `package.json`\n\n```js\n{\n \"scripts\": {\n \"optimizeImages\": \"tiny\"\n }\n}\n```\nor\n```js\n{\n \"scripts\": {\n \"optimizeImages\": \"tiny --once\" //only compress once no watching files change\n }\n}\n```\n\n## Author\n\nsudongyuer email:976499226@qq.com\n\n## License\n\n[MIT](./LICENSE) License © 2021 [SuDongYu](https://github.com/sudongyuer)\n"
}