diff --git a/scripts/turbo/index.js b/scripts/turbo/index.js index a7d539c5be64..42a93777849a 100644 --- a/scripts/turbo/index.js +++ b/scripts/turbo/index.js @@ -4,7 +4,21 @@ const path = require("path"); const runTurbo = async (task, args, { apiSecret, apiEndpoint, apiSignatureKey } = {}) => { const command = ["turbo", "run", task, "--concurrency=100%", "--output-logs=hash-only"]; + + const cacheReadWriteKey = process.env.AWS_JSV3_TURBO_CACHE_BUILD_TYPE ?? "dev"; + + const cacheReadWrite = { + // release is remote write-only + RELEASE: "--cache=local:,remote:w", + // preview is remote read/write + PREVIEW: "--cache=local:,remote:rw", + // dev is local read/write and remote read-only + dev: "--cache=local:rw,remote:r", + }; + + command.push(cacheReadWrite[cacheReadWriteKey]); command.push(...args); + const turboRoot = path.join(__dirname, "..", ".."); const turboEnv = {