Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular / create a module, component without css file in one command?

Is there such an option to create a Module that is linked to a component, which does not have a css file upon creation?

e.g.

The default way of doing this for me so far is the following:

ng generate module name / ng generate component name

And I get the basic structure of a component: name.component.css name.component.html name.component.spec.ts name.component.ts name.module.ts

And I want to create the following with only ONE query:

name.component.html name.component.spec.ts name.component.ts name.module.ts

e.g. something like:

ng g m name + c name - css ... you get the idea.

Is this possible, and if yes, how?

like image 721
Tanasos Avatar asked May 08 '18 13:05

Tanasos


People also ask

How do you make a component without spec ts?

You have to use "--skip-tests true" when generating component. (Note: you can get the above version info by trying "ng v" or "ng -v" in the terminal). You can get the complete list of switches for "ng g c (short for ng generate component)" using "ng g c --help". Alternatively you can add a component manually.

What is the command to generate a new module in Angular 7?

Getting Started With Angular 7 Once you have the angular cli installed, use the ng cli command to create a new Angular project.

Does Angular use css modules?

We can use CSS Modules with Angular through postcss-modules and posthtml-css-modules.


1 Answers

Minimalist Angular Cli generate example

ng g c hero-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

Link to the Angular doc reference https://angular.io/cli/generate#component

With all these parameters together,

The cli creates a single .ts file in the current folder and links it in the module.

like image 189
Vishesh Mishra Avatar answered Sep 17 '22 12:09

Vishesh Mishra