11const sharp = require ( `./safe-sharp` )
22const { generateImageData } = require ( `./image-data` )
33const imageSize = require ( `probe-image-size` )
4+ const { isCI } = require ( `gatsby-core-utils` )
45
56const _ = require ( `lodash` )
67const fs = require ( `fs-extra` )
@@ -151,6 +152,17 @@ function createJob(job, { reporter }) {
151152 return promise
152153}
153154
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+
154166function queueImageResizing ( { file, args = { } , reporter } ) {
155167 const fullOptions = healOptions ( getPluginOptions ( ) , args , file . extension )
156168 const {
@@ -170,13 +182,7 @@ function queueImageResizing({ file, args = {}, reporter }) {
170182 inputPaths : [ file . absolutePath ] ,
171183 outputDir,
172184 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 ( ) ,
180186 operations : [
181187 {
182188 outputPath : relativePath ,
@@ -244,13 +250,7 @@ function batchQueueImageResizing({ file, transforms = [], reporter }) {
244250 file . internal . contentDigest
245251 ) ,
246252 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 ( ) ,
254254 operations,
255255 pluginOptions : getPluginOptions ( ) ,
256256 } ,
@@ -341,7 +341,7 @@ async function generateBase64({ file, args = {}, reporter }) {
341341 info = result . info
342342 } catch ( err ) {
343343 reportError (
344- `Failed to process image ${ file . absolutePath } .
344+ `Failed to process image ${ file . absolutePath } .
345345It is probably corrupt, so please try replacing it. If it still fails, please open an issue with the image attached.` ,
346346 err ,
347347 reporter
@@ -773,3 +773,4 @@ exports.getImageSize = getImageSize
773773exports . getImageSizeAsync = getImageSizeAsync
774774exports . stats = stats
775775exports . _unstable_createJob = createJob
776+ exports . _lazyJobsEnabled = lazyJobsEnabled
0 commit comments