This is my environment. Please note this is also set in the relevant development modes and production modes.
Dev: https://ar.dev.loc/ https://en.dev.loc/ Live: https://ar.site.com/ https://en.site.com/
I am using a multi store setup with Arabic and English and everything is working well including building modules and template building.
However, if I make a change to any less file or JS file (despite using grunt less or grunt watch) I have to run the following commands on my development environment everything single time to see them on my local machine.
$ rm -rf var/cache var/page_cache var/view_preprocessed pub/static $ mkdir pub/static $ bin/magento setup:static-content:deploy $ bin/magento setup:static-content:deploy ar_SA $ grunt exec less // sometimes I leave this do this $ grunt // I swap between these
This takes a long time to do this process everytime. It is frustrating as I am fast coder and like to see CSS and Less immediately on the site and not wait around.
The quick approach what our team is doing is actually making changes in pub/static
and then we ship these to less and app/design
etc and then do the process above and then git.
Live server is pretty much the same. Git pull and then maintenance mode (madness on a live ecom site! Who build M2?? Then we run commands above - downtime of 45mins)
Surely there must be a quicker way for our deployment, development and team to work better and to see changes faster without downtime!
Even Magento 2 official documentation says your LIVE site needs to go into maintenance and downtime mode to publish content - this is not an option for us. The CTO are not happy. Simply absurd.
Related questions with people asking about faster development same issues:
Css changes reflect only after deploy command in magento2
Magento 2 static cache
Changes to CSS and JavaScript applies only after deploying static content
So I want to collate all the issues and resolve this.
The static view files deployment command enables you to write static files to the Magento file system when the Magento software is set for production mode. The term static view file refers to the following: “Static” means it can be cached for a site (that is, the file is not dynamically generated).
magento. env. yaml —centralizes the management of build and deploy actions across all of your environments, including Pro Staging and Production, using environment variables.
Static View Files Deployment Overview Static part refers to the files that can be cached if not generated dynamically and view — to the Model-View-Controller layer. You can find the static view files in the /pub/static (contains js, css, html and others) or /var/view_preprocessed directory (contains phtml files).
yes it can be faster by following steps :
you can find the file in pub static by following command
find pub/static -iname yourjsfile.js
.htaccess in pub/static send the missing files to pub/static.php with parameter resource and pub/static.php file creates an StaticResource for the file if available and deploy that.
Note: this only works with apache mod_rewrite
For Nginx you need to configure the same via nginx.conf.sample
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With