Laravel Elixir wrapper around imagemin Gulp task.
npm install laravel-elixir-imageminThis is a simple imagemin wrapper around Laravel Elixir. Add it to your Elixir-enhanced Gulpfile, like so:
```
npm install --save-dev laravel-elixir-imagemin
`javascript
var elixir = require('laravel-elixir');
require('laravel-elixir-imagemin');
elixir(function(mix) {
mix.imagemin();
});
`
This will scan your resources/assets/images directory for all image files.
If you want to process a different image directory, you can update your Elixir config by either:
#### Defining elixir.config.images in your Gulpfile
You can define elixir.config.images in your gulpfile.js like so:
`javascript
var elixir = require('laravel-elixir');
require('laravel-elixir-imagemin');
elixir.config.images = {
folder: 'img',
outputFolder: 'img'
};
elixir(function(mix) {
mix.imagemin();
});
`
#### Setting config.images in an elixir.json file
You can create an elixir.json
file in your project root to modify Elixir's default settings.
`json`
{
"images": {
"folder": "img",
"outputFolder": "img"
}
}
#### Upgrading from the old syntax
If you're upgrading from the old syntax, where you defined custom directories like so:
`javascript`
mix.imagemin("./resources/assets/img", "public/images/foo/bar/");
All you have to do is:
- Remove the first two parameters, then
- Follow the instructions for "Changing the default image directories"
Note: You don't define the full path anymore. Instead of resources/assets/img you simply use img, becauseassets
laravel-elixir-imagemin will look inside your and public directories (or whatever else you may have
configured).
You can override the default imagemin options by passing in an options object like so:
`javascript``
mix.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
});
Available imagemin options are listed here in the gulp-imagemin readme.