Skip to content

Commit b9dda91

Browse files
committedMay 2, 2018
add migration info to readme
1 parent ab4dc2c commit b9dda91

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed
 

‎README.md

+44
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,50 @@ For more details on each plugin's options, see their documentation on [Github](h
123123
}
124124
```
125125

126+
If you only want to run imagemin in production builds, you can omit the `img-loader` or leave plugins empty in your production configuration file. If you don't keep a separate configuration for prod builds, something like the following also works:
127+
128+
```js
129+
{
130+
loader: 'img-loader',
131+
options: {
132+
plugins: process.env.NODE_ENV === 'production' && [
133+
require('imagemin-svgo')({})
134+
// etc.
135+
]
136+
}
137+
}
138+
```
139+
140+
141+
## Migrating from 2.x
142+
143+
To get the default behavior from version `2.0.1`, you'll need to install these imagemin plugins:
144+
145+
* [imagemin-gifsicle](https://github.com/imagemin/imagemin-gifsicle)
146+
* [imagemin-mozjpeg](https://github.com/imagemin/imagemin-mozjpeg)
147+
* [imagemin-optipng](https://github.com/imagemin/imagemin-optipng)
148+
* [imagemin-svgo](https://github.com/imagemin/imagemin-svgo)
149+
150+
Then use this loader setup in your webpack configuration file:
151+
152+
```js
153+
{
154+
loader: 'img-loader',
155+
options: {
156+
plugins: [
157+
require('imagemin-gifsicle')({}),
158+
require('imagemin-mozjpeg')({}),
159+
require('imagemin-optipng')({}),
160+
require('imagemin-svgo')({})
161+
]
162+
}
163+
}
164+
```
165+
166+
The options object you had under a plugin's name property, should instead be passed directly to the plugin after you require it.
167+
168+
If you used the optional `pngquant` settings, then you will additionally need to install [imagemin-pngquant](https://github.com/imagemin/imagemin-pngquant), and add it to your plugins array as any other imagemin plugin.
169+
126170

127171
## License
128172

‎package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.