Working with Hyvä is something we felt essential the minute we heard about this amazing new Magento theme.
MDOQs managed Magento hosting is already hosting and supporting agencies and developers working with Hyvä-based Magento 2 websites.
Compatibility
There are only 3 requirements to make your MDOQ production and development instances fully Hyvä compatible:-
- Configure automatic installation of required packages such as: node, npm and yarn
- Provisioning & Deployment Pipeline automation - how to automatically build the theme assets for development or production
- Source Control - how to ensure your Node modules do not get added
Configure automatic installation
Within settings for the instance navigate to PHP-FPM settings
Within PHP-FPM paste the following
curl -o - https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" && nvm install 12.20.1 && nvm use 12.20.1 && npm install --global gulp-cli && npm install --global yarn
Change Run command as to magento
Click save and allow PHP-FPM to be recreated.
N.B - if you are using a configure script for php-fpm eg mdoq/php-fpm/configure and this script is running as root. Then you can add the following in the script
# Install Hyva deps
su -s /bin/bash magento -c 'curl -o - https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" && nvm install 12.20.1 && nvm use 12.20.1 && npm install --global gulp-cli && npm install --global yarn'
Provisioning & Deployment Pipeline automation for Hyvä compatibility
When you create new instance for Hyvä, your theme folder will require installation of the node modules which are used to build your static assets. Because MDOQ production infrastructure is optimised, these modules are only used and stored in non-production instances. Because MDOQ already comes with a full production deployment pipeline, the following changes can easily be incorporated into your Post Rollup Actions script.
When the below changes are incorporated into your project, your Hyvä theme will build consistently every time.
At the top of the file under INPUT="$1-$2"
add the following
# include user bin dirs in PATH export PATH=/home/magento/bin:/home/magento/.local/bin:/home/magento/.nvm/versions/node/v12.20.1/bin:${PATH}
Then incorperate the following
"$ARGUMENT_STEP_BEFORE_MAGENTO_COMMANDS-$ARGUMENT_COMPARISON_AHEAD")
set -xe
cd ~/htdocs/app/design/frontend/VENDOR/THEME/web/tailwind/; rm -rf node_modules && npm install && npm run build-prod
;;
"$ARGUMENT_STEP_BEFORE_MAGENTO_COMMANDS-$ARGUMENT_COMPARISON_IDENTICAL")
set -xe
cd ~/htdocs/app/design/frontend/VENDOR/THEME/web/tailwind/; rm -rf node_modules && npm install && npm run build-prod
;;
"$ARGUMENT_STEP_BEFORE_MAGENTO_COMMANDS-$ARGUMENT_COMPARISON_BEHIND")
set -xe
cd ~/htdocs/app/design/frontend/VENDOR/THEME/web/tailwind/; rm -rf node_modules && npm install && npm run build-prod
;;
Source Control
For your .gitignore file to be
################
# Hyvä on MDOQ #
################
app/design/frontend/*/*/web/tailwind/node_modules
app/design/frontend/*/*/web/css/styles.css
app/design/frontend/*/*/web/tailwind/tailwind-output.css