1
1
const sharp = require ( `./safe-sharp` )
2
2
const { generateImageData } = require ( `./image-data` )
3
3
const imageSize = require ( `probe-image-size` )
4
+ const { isCI } = require ( `gatsby-core-utils` )
4
5
5
6
const _ = require ( `lodash` )
6
7
const fs = require ( `fs-extra` )
@@ -151,6 +152,17 @@ function createJob(job, { reporter }) {
151
152
return promise
152
153
}
153
154
155
+ function lazyJobsEnabled ( ) {
156
+ return (
157
+ process . env . gatsby_executing_command === `develop` &&
158
+ ! isCI ( ) &&
159
+ ! (
160
+ process . env . ENABLE_GATSBY_EXTERNAL_JOBS === `true` ||
161
+ process . env . ENABLE_GATSBY_EXTERNAL_JOBS === `1`
162
+ )
163
+ )
164
+ }
165
+
154
166
function queueImageResizing ( { file, args = { } , reporter } ) {
155
167
const fullOptions = healOptions ( getPluginOptions ( ) , args , file . extension )
156
168
const {
@@ -170,13 +182,7 @@ function queueImageResizing({ file, args = {}, reporter }) {
170
182
inputPaths : [ file . absolutePath ] ,
171
183
outputDir,
172
184
args : {
173
- isLazy :
174
- ! (
175
- process . env . ENABLE_GATSBY_EXTERNAL_JOBS === `true` ||
176
- process . env . ENABLE_GATSBY_EXTERNAL_JOBS === `1`
177
- ) &&
178
- process . env . gatsby_executing_command === `develop` &&
179
- ! ! process . env . GATSBY_EXPERIMENTAL_LAZY_IMAGES ,
185
+ isLazy : lazyJobsEnabled ( ) ,
180
186
operations : [
181
187
{
182
188
outputPath : relativePath ,
@@ -244,13 +250,7 @@ function batchQueueImageResizing({ file, transforms = [], reporter }) {
244
250
file . internal . contentDigest
245
251
) ,
246
252
args : {
247
- isLazy :
248
- ! (
249
- process . env . ENABLE_GATSBY_EXTERNAL_JOBS === `true` ||
250
- process . env . ENABLE_GATSBY_EXTERNAL_JOBS === `1`
251
- ) &&
252
- process . env . gatsby_executing_command === `develop` &&
253
- ! ! process . env . GATSBY_EXPERIMENTAL_LAZY_IMAGES ,
253
+ isLazy : lazyJobsEnabled ( ) ,
254
254
operations,
255
255
pluginOptions : getPluginOptions ( ) ,
256
256
} ,
@@ -341,7 +341,7 @@ async function generateBase64({ file, args = {}, reporter }) {
341
341
info = result . info
342
342
} catch ( err ) {
343
343
reportError (
344
- `Failed to process image ${ file . absolutePath } .
344
+ `Failed to process image ${ file . absolutePath } .
345
345
It is probably corrupt, so please try replacing it. If it still fails, please open an issue with the image attached.` ,
346
346
err ,
347
347
reporter
@@ -773,3 +773,4 @@ exports.getImageSize = getImageSize
773
773
exports . getImageSizeAsync = getImageSizeAsync
774
774
exports . stats = stats
775
775
exports . _unstable_createJob = createJob
776
+ exports . _lazyJobsEnabled = lazyJobsEnabled
0 commit comments