Search code examples
javascriptangularfile-watcher

Angular 6 watcher does not compile imported less files in main.less


Am working on Angular version 6.

And I am using Less for styling.

In Angular previous Versions, I had to include less main file in angular_cli.json file and that worked perfectly for me.

In latest Angular 6 version we have a file called angular.json and I did the same thing. I have added the main.less file inside styles: [].

But the issue that I am facing is that for some reason when my watcher is running it compiles main.less file alone. Imported LESS files are compiling only when I restart the watcher.


Solution

  • I found the solution for this. Run this command

    npm install --save-dev less-loader@3.0.0 
    

    and I add this in angular.json

    "schematics": {
        "@schematics/angular:component": {
          "styleext": "less"
        }
      },
    

    This allowed Angular to generate less files by default.

    Thank you :-)