Skip to content

Instantly share code, notes, and snippets.

@progcode
Last active May 24, 2017 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save progcode/4c58e71e97053527e1fe12a0f98099f7 to your computer and use it in GitHub Desktop.
Save progcode/4c58e71e97053527e1fe12a0f98099f7 to your computer and use it in GitHub Desktop.
Magento2 less

npm install -g grunt-cli

project/magento2/dev/tools/grunt/configs/themes.js

mytheme: {
    area: 'frontend',
    name: 'YourProject/Theme',
    locale: 'en_US',
    files: [ 'your/theme/CSS' ],
    dsl: 'less'
},

blank: {
    area: 'frontend',
    name: 'Magento/blank',
    locale: 'en_US',
    files: [
        'css/styles-m',
        'css/styles-l',
        'css/email',
        'css/email-inline'
    ],
    dsl: 'less'
},
luma: {
    area: 'frontend',
    name: 'Magento/luma',
    locale: 'en_US',
    files: [
        'css/styles-m',
        'css/styles-l'
    ],
    dsl: 'less'
},
backend: {
    area: 'adminhtml',
    name: 'Magento/backend',
    locale: 'en_US',
    files: [
        'css/styles-old',
        'css/styles'
    ],
    dsl: 'less'
}

grunt exec:[theme] Cleans the static directory of existing assets and recreates them based on the current file system.

This command is essential. If ever you add new LESS files, Grunt won’t actually be able to know about them until you re-run this command so that it pulls LESS files from your theme folder into the pub/static directory.

grunt less[:your-theme] Compiles the LESS files that Grunt finds in the pub/static directory from the entry points defined in your your-project/magento2/dev/tools/grunt/configs/themes.js directory.

grunt watch Watches your pub/static directory for changes in files (which are replicated over the symlinks to your theme directory), then recompiles the LESS files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment