3

The following command in Angular CLI generates a new component with 3 files - HTML, TS and SCSS.

ng g c file --skip-import --spec false

I just need the HTML and CSS. I'm already skipping the spec file.. How do I tell it to skip creating the SCSS?

zer0
  • 4,657
  • 7
  • 28
  • 49
  • Does this answer your question? [Angular / create a module, component without css file in one command?](https://stackoverflow.com/questions/50234958/angular-create-a-module-component-without-css-file-in-one-command) – Ap0st0l Jan 13 '22 at 11:49

4 Answers4

8

Following angular command can be used in the terminal

ng g c something-component --flat -it -is --skipTests


     -is for inline css, preventing style file creation>
     --flat to prevent folder creation
     -it for inline template, preventing html file creation
     --skipTests to prevent .spec file creation

Try one of them as per your requirement

SHR
  • 7,940
  • 9
  • 38
  • 57
Prakash Khadka
  • 153
  • 2
  • 7
6

You need the option inlne styles, e.g.

ng g c file -is -spec false
Yakov Fain
  • 11,972
  • 5
  • 33
  • 38
1

You can also edit your angular-cli.json file to tell angular to create css file instead of scss

Open your angular-cli.json file from the root folder of your project.

Find the defaults key

...

"defaults": {
    "styleExt": "scss",
    "component": {}
}

...

and change the value of styleExt to css.

You should be good to go now.

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
0
ng g c component-name --skip-tests --style none

for future reference: you can issue ng g c --help to show all options regarding generating components

(edit: I reread your question, if you want to force create css instead of scss, use --style css instead)