Skip to content

Instantly share code, notes, and snippets.

@antony
Last active October 16, 2023 18:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antony/a01469ef144e63891579e1201d8e943d to your computer and use it in GitHub Desktop.
Save antony/a01469ef144e63891579e1201d8e943d to your computer and use it in GitHub Desktop.
WASM dependency on Vercel
#!/bin/bash
VERCEL_OUTPUT_DIR=.vercel_build_output
LAMBDA_DIR=.vercel_build_output/functions/node/render/
cp -r static $LAMBDA_DIR/static
cp node_modules/sharp/build/Release/*.node $LAMBDA_DIR
cp node_modules/canvas/build/Release/*.node $LAMBDA_DIR
cp node_modules/sharp/vendor/8.11.3/linux-x64/lib/libvips-cpp.so.42 $LAMBDA_DIR
cp ./images.json $VERCEL_OUTPUT_DIR
sed -i 's#\.\./build/Release#\.#g' $LAMBDA_DIR/index.js
echo "Moved production dependencies into their correct directories"
{
"scripts": {
"build": "svelte-kit build && sh ./fix-sharp.sh"
}
}
@antony
Copy link
Author

antony commented Oct 16, 2023

Note that this is for Vercel Filesystem API v1/v2. For the new Build Output API v3 which builds into a dir called .vercel, you probably need to change that top variable name. You may need to modify other things, I've not upgraded this project yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment