1

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
$ php -dmemory_limit=1G bin/magento setup:static-content:deploy -f //even if I use --theme Mythemename -f
$ 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 like to see CSS and Less immediately on the site and not wait around.

Surely there must be a quicker way for our deployment, development 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.

1
  • Hello @Muhammad, why don't you use developer mode ?
    – Pawan
    Commented Feb 8, 2019 at 17:43

4 Answers 4

1

There are various options available to allow you to run command for specific cases.

Please check the options below:

Options:

  -f, --force                                Deploy files in any mode.
  -s, --strategy[=STRATEGY]                  Deploy files using specified strategy. [default: "quick"]
  -a, --area[=AREA]                          Generate files only for the specified areas. [default: ["all"]] (multiple values allowed)
      --exclude-area[=EXCLUDE-AREA]          Do not generate files for the specified areas. [default: ["none"]] (multiple values allowed)
  -t, --theme[=THEME]                        Generate static view files for only the specified themes. [default: ["all"]] (multiple values allowed)
      --exclude-theme[=EXCLUDE-THEME]        Do not generate files for the specified themes. [default: ["none"]] (multiple values allowed)
  -l, --language[=LANGUAGE]                  Generate files only for the specified languages. [default: ["all"]] (multiple values allowed)
      --exclude-language[=EXCLUDE-LANGUAGE]  Do not generate files for the specified languages. [default: ["none"]] (multiple values allowed)
  -j, --jobs[=JOBS]                          Enable parallel processing using the specified number of jobs. [default: 0]
      --symlink-locale                       Create symlinks for the files of those locales, which are passed for deployment, but have no customizations.
      --content-version=CONTENT-VERSION      Custom version of static content can be used if running deployment on multiple nodes to ensure that static content version is identical and caching works properly.
      --refresh-content-version-only         Refreshing the version of static content only can be used to refresh static content in browser cache and CDN cache.
      --no-javascript                        Do not deploy JavaScript files.
      --no-css                               Do not deploy CSS files.
      --no-less                              Do not deploy LESS files.
      --no-images                            Do not deploy images.
      --no-fonts                             Do not deploy font files.
      --no-html                              Do not deploy HTML files.
      --no-misc                              Do not deploy files of other types (.md, .jbf, .csv, etc.).
      --no-html-minify                       Do not minify HTML files.
  -h, --help                                 Display this help message
  -q, --quiet                                Do not output any message
  -V, --version                              Display this application version
      --ansi                                 Force ANSI output
      --no-ansi                              Disable ANSI output
  -n, --no-interaction                       Do not ask any interactive question
  -v|vv|vvv, --verbose                       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

You can use any option in the following way:

php bin/magento setup:static-content:deploy [--option]

For example: If you want to deploy content for the front end only and for the Luma theme only, then the following command will work:

php bin/magento setup:static-content:deploy --area=frontend --theme=Magento/luma
2
  • I was stuck in this problem link can please me @mohit Commented Feb 8, 2019 at 11:50
  • @mohit thanks for the reply much appreciated but I already know these specific cases that you mentioned if you check my commands that I mentioned in question I specifically mentioned in comment like "php -dmemory_limit=1G bin/magento setup:static-content:deploy -f //even if I use --theme Mythemename -f". I am looking for much more, a more better way to fasten the deployment process Commented Feb 9, 2019 at 7:35
0

You can use --jobs parameter with static content deploy command as below .

sudo php bin/magento setup:static-content:deploy -f -j=4

So static content deployment will be execute in 4 parallel threads.

1
  • I don't think you should use sudo... if you have to, then your server configuration isn't right
    – Zankar
    Commented Oct 6, 2021 at 7:14
0

For development you can try this:

  1. php bin/magento config:set dev/front_end_development_workflow/type client_side_compilation
  2. php bin/magento cache:flush

Reference to official DevDocs: https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/css-guide/css_quick_guide_mode.html#using-client-side-compilation-mode

0

What i can suggest is to change your deployment strategy and build ready pre-built images which just need to be deployed - either using Docker or Kubernetes.

That way you can clearly separate the building from deployment process.

The only downtime we have doing this currently on a live website is when we are applying the module changes (setup:upgrade) - which is probably less than 3-4 seconds at most.

If you want write to me at Skype: miracle_bg and i can give you further details and may be even parts of our CI/CD process (using github actions and docker).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.