title: Angular: how to override @Component()
body: <p>in our project we are building the same angular-application for different areas (lets say intranet and internet). The only thing that changes in those areas is *.scss-files. To be able to add scss-files conditionally, according to build-parameters I started overriding <code>@Component()</code> following this: </p>
  
  <p><a href="https://stackoverflow.com/a/39755547/1053622">https://stackoverflow.com/a/39755547/1053622</a></p>
  
  <p>which looks like this: </p>
  
  <pre><code>import { Component } from '@angular/core';
  
  export interface ITargetAwareComponentProperties {
    selector: string;
    template?: string;
    templateUrl?: string;
    styles?: string[];
    styleUrls?: string[];
    directives?: any;
    providers?: any;
    encapsulation?: number;
    internetStyles?: string[];
    intranetStyles?: string[];
  }
  
  export function TargetAwareComponent(properties: ITargetAwareComponentProperties) {
    try {
      if (!properties.styles) {
        properties.styles = [];
      }
  
      if (environment.targetType === 'intranet' &amp;&amp; properties.intranetStyles) {
        for (const style of properties.intranetStyles) {
          properties.styles.push(style);
        }
      }
      else if (properties.internetStyles) {
        for (const style of properties.internetStyles) {
          properties.styles.push(style);
        }
      }
  
    } catch (err) {
      console.warn(err);
    }
  
    return Component(properties);
  }
  </code></pre>
  
  <p>This is working fine until I want to compile it ahead of time with <code>ng build --aot</code> where I am getting the following error message: </p>
  
  <pre><code>ERROR in : Unexpected value 'TextComponent' 
  in /Users/.../components/text/text.component.ts' 
  declared by the module 'AppCommonModule in /Users/.../common.module.ts'. 
  Please add a @Pipe/@Directive/@Component annotation.
  </code></pre>
  
  <p>I am guessing that angular doesn't understand that <code>@TargetAwareComponent()</code> is a <code>@Component()</code> and therefore does not compile/finds it properly.</p>
  
  <p>I guess it is not really supported to override the @Component() itself, right? </p>
  
  <p>Is there another way to do it?  </p>
  
  <p>Otherwise I will need to copy/move/paste/delete *.scss-files before I run <code>ng build --aot</code></p>
  
  <p>Help is appreciated.</p>