Commit 3bb0ddb
authored
webpack: detect if node-zopfli is installed before attemping to use it (#4712)
zopfli is not required by any means, especially for local development
and CI. So if there's an issue installing this, we should just avoid
attempting to compress rather than error all over the place. This keeps
the error to just a simple warning instead so we're aware and can see
this if something were to fail in a production build, but won't affect
any other environment.
Also, note that this is explicitly checking against paths rather than
testing with a `require()` since with npm@2, the dependency is actually
a sub-dependnecy of `compression-webpack-plugin` and can't be `require`d
from outside that module. So it doesn't help to test that. And with
npm@3, the module gets flatted to the top level, so we need to check
both places.1 parent 45c42b7 commit 3bb0ddb
1 file changed
+15
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
188 | 198 | | |
189 | 199 | | |
190 | 200 | | |
191 | 201 | | |
| 202 | + | |
192 | 203 | | |
193 | 204 | | |
194 | 205 | | |
195 | | - | |
| 206 | + | |
196 | 207 | | |
197 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
198 | 212 | | |
199 | 213 | | |
200 | 214 | | |
0 commit comments