How to create a component with LESS framework using angular CLI command?

1.2k Views Asked by At

My angular project is defaulted to CSS styling framework. But for some components I need to adopt LESS framework. I tried the following command to create the component with LESS framework but still the component is generated with CSS file.

ng g c testFolder/components/test-component --export=true --module=test-module --style=less

Can somebody tell me how do I create my component with LESS framework by not changing the defaults in my project?

2

There are 2 best solutions below

0
whyour On BEST ANSWER

ng g c testFolder/components/test-component --style=less

this can not cahnge the defaults in project.

ng generate component

0
Masoud Bimar On

based on Angular Documentation: Angular Documentation

set the default style on an existing project:

ng config schematics.@schematics/angular:component.styleext less
# note: @schematics/angular is the default schematic for the Angular CLI

Manually change in .angular-cli.json (Angular 5.x and older) or angular.json(Angular 6+) or run:

ng config defaults.styleExt=scss

Rename your existing .css files to .less (i.e. styles.css and app/app.component.less)

After changing defaults, every component create with Less file by default