2

Most of time spend on setup:upgrade and setup:static-content:deploy. Is it compulsory to run both command after changes on less file? I have used Default lUMA theme.

0

You don't have to run setup:upgrade:command if the changes you have made only are in less files.

However you have to run setup:static-content:deploy to see less files changes, also you can deploy static content from admin as well ( Magento 2 CE ):

System->Cache Management -> Flush static files ( bottom of page ).

7
  • You mean After changes any less file, Only I need to run php bin/magento cache:flush ? Aug 20 '18 at 11:31
  • No, in admin go to cache management section there will be a button " Flush Static Files" , it will redeploy static files Aug 20 '18 at 11:45
  • It Breaks css load. When I check pub/static folder Fronted folder is not exists. Then Again I need to fire all deploy command. Aug 20 '18 at 12:22
  • did you check if there is any permission issue ? are you deploying static content forcefully ? using command -f Aug 21 '18 at 7:49
  • I am in windows. there are no any permission issue. I use System->Cache Management -> Flush static files ( bottom of page ). so no need to make any command if we are from admin GUI side. Aug 21 '18 at 7:53
0

you can follow these steps:

1.Install Grunt Cli tool by runnig this command npm install -g grunt-cli

2.cd your_Magento_instance_directory

3.Rename package.json.sample to package.json and Gruntfile.js.sample to Gruntfile.js

4.run npm install

5.Create you own theme (ex:Sample/Mytheme) I guess it's already done ;)

6.Create a less file like that app/design/frontend/Sample/Mytheme/web/css/source/_theme.less and add this code

body{
  background-color:red;
}

7.add the below code to the file dev/tools/grunt/configs/themes.js

mytheme>: {
area: 'frontend',
name: 'Sample/Mytheme',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
}
  1. grunt clean
  2. grunt exec:mytheme
  3. grunt less:mytheme
  4. Afterwards, reload the frontend page , your background color should be changed to red.

If you run grunt watch and you change your less file Grunt will automatically update all necessary files .

I hope my answer was clear. Good luck and happy coding !!!

1
  • Dear friends. In Ubuntu command works fast. I am using Windows and command processes slow. So let me know if you have any solution for windows. Aug 29 '18 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.