Skip to content

Instantly share code, notes, and snippets.

@toan-tam
Last active May 5, 2022 08:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toan-tam/a5bd795f846fb1243f096648f5bce4f9 to your computer and use it in GitHub Desktop.
Save toan-tam/a5bd795f846fb1243f096648f5bce4f9 to your computer and use it in GitHub Desktop.
.magento.app.yaml build hook
# We run build hooks before your application has been packaged.
build: |
set -e
echo "\n================================== Install and configure Baler - Start =================================="
echo "================= Install and configure Baler - Upgrade node version 14.4.0 - Start ================="
unset NPM_CONFIG_PREFIX
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | dash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm current
nvm install 14.4.0
echo "================= Install and configure Baler - Upgrade node version 14.4.0 - End ================="
echo "================= Install and configure Baler - Install AMD module baler - Start ================="
echo "================= See https://github.com/magento/baler for more information ================="
git clone https://github.com/magento/baler.git
cd baler
npm install
npm test
npm run build
npm link
cd ..
echo "================= Install and configure Baler - Install AMD module baler - End =================\n"
php ./vendor/bin/ece-tools run scenario/build/generate.xml
echo "\n================================== Install and configure Baler - Run baler - Start =================================="
baler
echo "================================== Install and configure Baler - Run baler - End ==================================\n"
echo "\n================================== Minify JS files using Terser after Baler is run - Start =================================="
npm install -g terser
echo "Find all non-minified files, except for the ones created by Baler and run them through Terser (This could take a few minutes to run) ..."
find 'pub/static/frontend/Magento/luma' \( -name '*.js' -not -name '*.min.js' -not -name 'core-bundle.js' -not -name 'requirejs-bundle-config.js' \) -exec terser \{\} -c -m reserved=['$','jQuery','define','require','exports'] -o \{\} \;
echo "================================== Minify JS files using Terser after Baler is run - End ==================================\n"
php ./vendor/bin/ece-tools build:transfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment