Examples

Following are some example commands.

Excluding a theme and HTML minification

The following command deploys static content for the US English (en_US) language, excludes the Luma theme provided with Commerce, and does not minify HTML files.

bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify

Sample output:

Requested languages: en_US
Requested areas: frontend, adminhtml
Requested themes: Magento/blank, Magento/backend
=== frontend -> Magento/blank -> en_US ===
=== adminhtml -> Magento/backend -> en_US ===
...........................................................
... more ...
Successful: 2055 files; errors: 0
---

New version of deployed files: 1466710645
............
Successful: 1993 files; errors: 0
---

The following command deploys only JavaScript, with 4 jobs, with a standard deployment strategy:

bin/magento setup:static-content:deploy -s standard --no-misc --no-html --no-fonts --no-images --no-less --no-css -j 4

The following command deploys only CSS and LESS with 3 jobs, and a quick deployment strategy:

bin/magento setup:static-content:deploy -s quick --no-misc --no-html --no-fonts --no-images --no-javascript -j 3

Generating static view files for one theme and one area

The following command generates static view files for all languages, the frontend area only, the Commerce Luma theme only, without generating fonts:

bin/magento setup:static-content:deploy --area frontend --no-fonts --theme Magento/luma

Sample output:

Requested languages: en_US
Requested areas: frontend
Requested themes: Magento/luma
=== frontend -> Magento/luma -> en_US ===
...........................................................
... more ...
........................................................................
Successful: 2092 files; errors: 0
---

New version of deployed files: 1466711110

Deploy static view files without installing Commerce

You might want to run the deployment process in a separate, non-production, environment, to avoid any build processes on sensitive production machines.

To do this, take the following steps:

  1. Run bin/magento app:config:dump to export the configuration from your production system.
  2. Copy the exported files to the non-production code base.
  3. Deploy static view files: bin/magento setup:static-content:deploy

Troubleshooting the static view files deployment tool

Install the Commerce software first; otherwise, you cannot run the static view files deployment tool.

Symptom: The following error is displayed when you run the static view files deployment tool:

ERROR: You need to install the Commerce application before running this utility.

Solution:

Use the following steps:

  1. Install the Commerce software using the command line.
  2. Log in to the application server as, or switch to, the file system owner.
  3. Delete the contents of <app_root>/pub/static directory, except for the .htaccess file. Do not delete this file.
  4. Deploy static view files: bin/magento setup:static-content:deploy

Tip for developers customizing the static content deployment tool

When creating a custom implementation of the static content deployment tool, use only atomic file writing for files that should be available on the client. If you use non-atomic file writing, those files might be loaded on the client with partial content.

One of the options for making it atomic is to write to files stored in a temporary directory and copying or moving them to the destination directory (from where they are loaded to client) after writing is over. For details about writing to files, see php fwrite.

Commerce