Create symlinks to LESS files

First steps

  1. Log in to the Magento server as, or switch to, a user who has permissions to write to the Magento file system. One way to do this is to switch to the Magento file system owner.

    If you use the bash shell, you can also use the following syntax to switch to the Magento file system owner and enter the command at the same time:

    su <Magento file system owner> -s /bin/bash -c <command> If the Magento file system owner does not allow logins you can do the following
    
    sudo -u <Magento file system owner>  <command>
    
  2. To run Magento commands from any directory, add <your Magento install dir>/bin to your system PATH.

    Because shells have differing syntax, consult a reference like unix.stackexchange.com.

    bash shell example for CentOS:

    export PATH=$PATH:/var/www/html/magento2/bin
    

You can also run the commands in the following ways:

  • cd <your Magento install dir>/bin and run them as ./magento <command name>
  • php <your Magento install dir>/bin/magento <command name>

<your Magento install dir> is a subdirectory of your web server's docroot. Need help locating the docroot? Click here.

In addition to the command arguments discussed here, see Common arguments.

Create LESS files

This command enables you to create symlinks to LESS files.

Command options:

magento dev:source-theme:deploy [--type="..."] [--locale="..."] [--area="..."] [--theme="..."] [file1] ... [fileN] 

The following table discusses the meanings of this command’s parameters and values.

Parameter Value Required?

--type

Type of source files: [less] (default: "less")

Currently, LESS is the only file type supported.

No

--locale

Locale code.

To display the list of locale codes, enter magento info:language:list

No

--area

Area (adminhtml for the administrative area, frontend for the storefront).

No

--theme

Theme name in <VendorName>/<theme name> format. For example, Magento/blank or Magento/backend.

No

<file>

Space-separated list of CSS files to convert to LESS without the .css extension. (Default is css/styles-m css/styles-l, for adminhtml type css/styles css/styles-old)

No

For example, to create LESS files for the frontend theme named VendorName/themeName in the en_US locale using a CSS file named <your Magento install dir>/pub/static/frontend/VendorName/themeName/en_US/css/styles-l.css, enter the following command:

magento dev:source-theme:deploy --type="less" --locale="en_US" --area="frontend" --theme="VendorName/themeName" css/styles-l

The following messages display to confirm success:

Processed Area: frontend, Locale: en_US, Theme: VendorName/themeName, File type: less.
-> css/styles-l.less
Successfully processed.

To create LESS files for the adminhtml, enter the following command:

magento dev:source-theme:deploy --locale="en_US" --area="adminhtml" --theme="Magento/backend" css/styles css/styles-old