1

I don't understand how can configure grunt to get the files i want and write where i want.

I'm in Magento 2, and have my own theme, I want Grunt to get the files in: app/design/frontend/Name/theme/web/css/source/_theme.less

and update:

app/design/frontend/Name/theme/web/css/my.css

but i don't know how to put it in grunt.

UPDATE

I'm the only one with grunt v0.4.5, who doesn't have the grunt.initConfig in his Gruntfile

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

2 Answers 2

0

That is better if you take a look here: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css_debug.html#grunt_prereq

For example, we have a custom theme:

enter image description here

Your Grunt config should be dev/tools/grunt/configs/themes.js

Theme: {
        area: 'frontend',
        name: 'Vendor/Theme',
        locale: 'en_US',
        files: [
            'css/styles-m',
            'css/styles-l',
            'css/my' // Your custom less file should be here.
        ],
        dsl: 'less'
    }
4
  • why i need " 'css/styles-m','css/styles-l', "? And how i can set the output .css file
    – Muribury
    Jan 24, 2017 at 10:23
  • You should read more here: devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/… Jan 24, 2017 at 10:29
  • yes, but i don't understand, and if i put that files grunt error appear: Unable to resolve the source file for 'frontend/Name/theme/de_CH/css/styles-m.less'
    – Muribury
    Jan 24, 2017 at 10:45
  • without it, grunt create a .css file, but it's empty
    – Muribury
    Jan 24, 2017 at 10:46
0

You can take a look at dev/tools/grunt/configs/themes.js. Here is the one they have on github.

In that file you can see how Blank and Luma are set up. After that it is a pretty straightforward process to copy them and add your less files there.

Please note that the vendor and theme names are case sensitive.

You will know you got it right if running grunt exec:yourthemename doesn't give you any errors.

After having suffered a lot with grunt myself, I would advise regularly cleaning every directory listed on the frontend developer guide in the devdocs after setting up grunt.

Also, after spending a couple of hours trying to get grunt watch to work with my theme, I just found that the feature is simply broken (you can skip to the end if too bored to read it all).

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.