Skip to content

Commit 8e7f613

Browse files
authored
fix(sharp): escape path and simplify env setting (#238)
1 parent ac0a6c6 commit 8e7f613

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

packages/open-next/src/build.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -320,28 +320,20 @@ function createImageOptimizationBundle() {
320320
// Target should be same as used by Lambda, see https://github.com/sst/sst/blob/ca6f763fdfddd099ce2260202d0ce48c72e211ea/packages/sst/src/constructs/NextjsSite.ts#L114
321321
// For SHARP_IGNORE_GLOBAL_LIBVIPS see: https://github.com/lovell/sharp/blob/main/docs/install.md#aws-lambda
322322

323+
const nodeOutputPath = path.resolve(outputPath);
324+
323325
//check if we are running in Windows environment then set env variables accordingly.
324-
if (process.platform === "win32") {
325-
cp.execSync(
326-
`set SHARP_IGNORE_GLOBAL_LIBVIPS=1 && npm install --arch=arm64 --platform=linux --target=18 --libc=glibc --prefix=${path.resolve(
327-
outputPath,
328-
329-
{
330-
stdio: "inherit",
331-
cwd: appPath,
332-
},
333-
);
334-
} else {
335-
cp.execSync(
336-
`SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=arm64 --platform=linux --target=18 --libc=glibc --prefix=${path.resolve(
337-
outputPath,
338-
339-
{
340-
stdio: "inherit",
341-
cwd: appPath,
326+
cp.execSync(
327+
`npm install --arch=arm64 --platform=linux --target=18 --libc=glibc --prefix="${nodeOutputPath}" [email protected]`,
328+
{
329+
stdio: "inherit",
330+
cwd: appPath,
331+
env: {
332+
...process.env,
333+
SHARP_IGNORE_GLOBAL_LIBVIPS: "1",
342334
},
343-
);
344-
}
335+
},
336+
);
345337
}
346338

347339
function createStaticAssets() {

0 commit comments

Comments
 (0)