{"id":17037778,"url":"https://github.com/heldr/grunt-smushit","last_synced_at":"2025-04-12T13:51:09.724Z","repository":{"id":3591455,"uuid":"4655193","full_name":"heldr/grunt-smushit","owner":"heldr","description":"Grunt task to optimize images using reSmush.it","archived":false,"fork":false,"pushed_at":"2016-03-27T15:04:48.000Z","size":1075,"stargazers_count":83,"open_issues_count":0,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T08:23:43.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heldr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-13T19:35:39.000Z","updated_at":"2024-10-12T08:14:16.000Z","dependencies_parsed_at":"2022-09-04T23:01:09.790Z","dependency_job_id":null,"html_url":"https://github.com/heldr/grunt-smushit","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heldr%2Fgrunt-smushit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heldr%2Fgrunt-smushit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heldr%2Fgrunt-smushit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heldr%2Fgrunt-smushit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heldr","download_url":"https://codeload.github.com/heldr/grunt-smushit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248575694,"owners_count":21127247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T08:55:04.902Z","updated_at":"2025-04-12T13:51:09.703Z","avatar_url":"https://github.com/heldr.png","language":"JavaScript","readme":"# grunt-smushit [![Build Status](https://secure.travis-ci.org/heldr/grunt-smushit.svg)](http://travis-ci.org/heldr/grunt-smushit)\n\nGrunt plugin to remove unnecessary bytes of PNG and JPG using reSmush.it\n\n\u003e reSmush.it is a FREE alternative to Yahoo Smush.it (deprecated on March 2015). This tool provides a online way to optimize pictures size via a documented webservice.\n\n[Read more about reSmush.it](http://resmush.it/)\n\nPrefer Gulp? [gulp-smushit](https://github.com/heldr/gulp-smushit)\n\n## Getting Started\nThis plugin requires Grunt `0.4.x`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-smushit --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-smushit');\n```\n\n## The \"smushit\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `smushit` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  smushit: {\n    mygroup: {\n      src: ['tests/img/**/*.png','tests/img/**/*.jpg'],\n      dest: 'tests/img/min'\n    }\n  }\n});\n```\n\n### Options\n\n#### options.service\nType: `String`\nDefault value: `null`\nCall another service instead of Yahoo Smushit\n\n#### options.verbose\nType: `boolean`\nDefault value: `true`\nShow image compressing rate log\n\n### Usage Examples\n\n#### Output Folder\nMove your files to a target folder (should not be into the same).\n\n```js\ngrunt.initConfig({\n  smushit: {\n\n    // catch all files from a single folder\n    group1: {\n      src: 'tests/img',\n      dest: 'tests/opt_img'\n    },\n\n    // filter by filetype\n    group2: {\n      src: ['tests/img/**/*.png','tests/img/**/*.jpg'],\n      dest: 'tests/img/min'\n    },\n\n    // set each file\n    group3:{\n        src: ['tests/img/logo.png','tests/img/whatever.png'],\n        dest: 'tests/img/min'\n    }\n\n  }\n});\n```\n\n#### Replace files\nBe safe to replace all of your old files with this option.\n\n```js\ngrunt.initConfig({\n  smushit: {\n\n    // a single directory\n    group1: {\n      src: 'tests/img'\n    },\n\n    // filter by filetype\n    group2: {\n      src: ['tests/img/**/*.png','tests/img/**/*.jpg']\n    },\n\n    //replace recursive\n    group3: {\n      src: ['tests/img/logo.png','tests/img/tellme.jpg']\n    }\n\n  }\n});\n```\n\n#### Work with a nested folder\nRecursively walk into folders and smushit files\n\n```js\ngrunt.initConfig({\n  smushit: {\n\n    // catch all files from a nested folder\n    group1: {\n      src: 'tests/nested/img',\n      dest: 'tests/opt_img'\n    },\n\n    // filter files in a nested folder by filetype\n    group2: {\n      src: ['tests/nested/img/**/*.png','tests/nested/img/**/*.jpg'],\n      dest: 'tests/opt_img'\n    },\n\n    // retrieve files in a nested folder by file name\n    group3: {\n      src: ['tests/nested/img/**/southpark.png','tests/nested/img/**/southpark.jpg'],\n      dest: 'tests/opt_img'\n    },\n  }\n});\n```\n\n#### Provide multiple source\nSmushit one folder, or many of them\n\n```js\ngrunt.initConfig({\n  smushit: {\n\n    // catch all files from a nested folder\n    group1: {\n      src: ['tests/img1', 'tests/img2'],\n      dest: 'tests/opt_img'\n    },\n\n    // filter files in a folder by filetype\n    group2: {\n      src: ['tests/img1/**/*.png','tests/img2/**/*.jpg'],\n      dest: 'tests/opt_img'\n    },\n\n    // retrieve files in a folder by file name\n    group3: {\n      src: ['tests/img1/**/southpark.png','tests/img2/**/southpark.jpg'],\n      dest: 'tests/opt_img'\n    },\n  }\n});\n```\n\n#### Use of cwd\nProvide your base directory\n\n```js\ngrunt.initConfig({\n  smushit: {\n\n    // src folder is 'tests/img' and dest is 'tests/opt_img'\n    group1: {\n      cwd: 'tests'\n      expand: true,\n      src: 'img',\n      dest: 'tests/opt_img'\n    },\n\n    // multiple src folders: src folder is ['tests/img1', 'tests/img2'] and dest is 'tests/img/min'\n    group2: {\n      cwd: 'tests'\n      expand: true,\n      src: ['img1/**/*.png','img2/**/*.jpg'],\n      dest: 'tests/img/min'\n    },\n  }\n});\n```\n\n\n#### Your own service\nThere is an option that you can set your own image optimizer service. Its a good alternative if you don't want to wait for smush.it web service latency.\n\n```js\ngrunt.initConfig({\n  smushit: {\n    options: {\n      service: 'http://myimgopt.com/exec'\n    },\n    mygroup: {\n      src: ['tests/img/**/*.png','tests/img/**/*.jpg'],\n      dest: 'tests/img/min'\n    }\n  }\n});\n```\n\n## Contributing\n\n```cli\n$ git clone git://github.com/heldr/grunt-smushit.git\n$ cd grunt-smushit\n$ npm install\n$ npm test\n```\nNOTE: Be sure to keep up to date the plugin tests and jshint code quality.\n\n## Release History\n  * 2015-09-05   v2.0.0   Use resmush.it due Yahoo Smushit deprecation\n  * 2014-05-19   v1.3.0   Pass node-smushit options through grunt file\n  * 2014-03-30   v1.2.1   Bugfix. Fixes [issue 29](https://github.com/heldr/grunt-smushit/issues/29)\n  * 2014-03-03   v1.2.0   Use cwd only for source files, following the [grunt pattern][grunt-cwd-pattern]\n  * 2013-07-15   v1.1.0   Support nested folder structure, support for multiple source folders\n  * 2013-07-15   v1.1.0   Enable the use of cwd parameter\n  * 2013-06-16   v1.0.0   Rewrite task on top of [grunt-init-gruntplugin][grunt-init-gruntplugin]\n  * 2013-05-26   v0.4.2   Add support to different service #16\n\n## Credits\n  * [node-smushit][node-smushit]\n\n## License\n\nMIT License\n(c) [Helder Santana](http://heldr.com)\n\n[node-smushit]: https://github.com/colorhook/node-smushit\n[grunt-init-gruntplugin]: https://github.com/gruntjs/grunt-init-gruntplugin\n[grunt-cwd-pattern]: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically\n","funding_links":[],"categories":["Image Optimizers"],"sub_categories":["Meetups"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheldr%2Fgrunt-smushit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheldr%2Fgrunt-smushit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheldr%2Fgrunt-smushit/lists"}