L
L
Ler Den2018-05-05 14:14:53
Angular
Ler Den, 2018-05-05 14:14:53

How to disable a component during build?

I do not want to demolish the component completely, but in the next build it is not needed. Any options on how to disable it so that angular cli doesn't enable it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dmitrygavrish, 2018-05-05
@dmitrygavrish

In src/environments are environment.ts, environment.prod.ts. In dev mode, the first is used, in prod - the second. And by default there is at least one field - production: true/false.
Accordingly, in your module file we write something like this:

let declarations = [SomeComponent];

if (!environment.production) {
 const devDeclarations = [/*ваши дев компоненты*/];
 declarations = declarations.concat(devDeclarations); // равносильно [...declarations, ...devDeclarations]
}

@NgModule({
  declarations,
  /*...*/
})
export class SomeModuleClass {}

S
Sergey, 2018-05-05
@Sergamers

It is not entirely clear what is not included. Don't declare. Or I'll use environments and do a check. If prod, then . . .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question