The process of converting the libwebp project from C/C++ to WASM is achieved using the Emscripten compiler. The general workflow is as follows:
This includes installing emsdk, cmake, and pnpm. For specific installation methods, refer to the Emscripten official documentation, pnpm official documentation, and installing cmake.
git submodule update --init --recursive --remote --rebaseIf you are using zsh, it is recommended to install the dotenv plugin to enable features like setting environment variables if a .env file is present in the current directory.
pnpm build:macdocker build -f ./docker/Dockerfile -t libwebp-wasm/img2webp:latest .docker run --rm -v $(pwd)/dist:/img2webp/dist -v $(pwd)/es:/img2webp/es -v $(pwd)/lib:/img2webp/lib libwebp-wasm/img2webp:latestNote: The modification of upstream submodule project code is currently done by running the git apply command. Sometimes you need to commit your own changes in the submodule directory and manually generate the patch.
pnpm build:patchMIT
