0

Good morning,

I'm pretty new to Magento 2 and I'm currently in the process of trying to get my first custom M2 theme up and running.

I have managed to create my new theme but running into trouble when trying to get the Grunt LESS task running.

I have been following the Magento docs and do the following...

  • added in the package.json, Gruntfile.js, and grunt-config.json files
  • ran npm install && npm update
  • I've then proceeded to add a local-themes.js file and update it to contain the following...
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

'use strict';

/**
* Define Themes
*
* area: area, one of (frontend|adminhtml|doc),
* name: theme name in format Vendor/theme-name,
* locale: locale,
* files: [
* 'css/styles-m',
* 'css/styles-l'
* ],
* dsl: dynamic stylesheet language (less|sass)
*
*/
module.exports = {
 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'
 },
 alpha: {
     area: 'frontend',
     name: 'SC/alpha',
     locale: 'en_GB',
     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'
 }
};

My grunt-config.json is as follows...

{
    "themes": "dev/tools/grunt/configs/local-themes"
}
  • Then when I try running the grunt exec:alpha command I get the following error...
Running "exec:alpha" (exec) task
Verifying property exec.alpha exists in config...ERROR
>> Unable to process task.
Warning: Required config property "exec.alpha" missing. Use --force to continue.

Aborted due to warnings.

Running the grunt exec command by itself references the blank and luma themes but not my custom theme.

Really not sure on how to proceed with this, has anyone else encountered this problem before?

Any help on this would be greatly appreciated.

1 Answer 1

2

Try to leave the default themes.js untouched and copy everything over to local-themes.js and add your own theme there.

Maybe also try using another name than "default" for the property.

8
  • Agreed, using default as a name may be causing issues.
    – Ben Crook
    Commented May 6, 2020 at 10:26
  • Thanks for the suggestions, I reverted the theme.js back to default and copied the contents over to local-theme.js and included my theme there. I've updated the theme name to be SC/alpha and I'm still getting the same error. Commented May 6, 2020 at 10:30
  • can you post your full local-themes.js file? Maybe there's a problem in your json. For example: Make sure that there's a comma after the } of the last default theme and before you add your theme
    – Chaz
    Commented May 6, 2020 at 10:38
  • Hey @Chaz, Thanks for getting back to me. I've updated my original question to include the full local-themes.js file contents. Commented May 6, 2020 at 10:47
  • I tried you local-themes.js file on my machine and I don't get the same error. The full path to the file in your project is dev/tools/grunt/configs/local-themes.js right? And If you run exec commands for the other themes they work? Do other commands like clean work for your theme?
    – Chaz
    Commented May 6, 2020 at 11:07

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.