2

I'm replacing html files with angular.js configurations, but if I need to replace a typescript file from component, it shows errors. I'm using angular 8.

angular.js

"production": {
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts", // GOOD
      "with": "src/environments/environment.prod.ts"
    },
    {
      "replace": "src/theme.css", // GOOD
      "with": "src/theme.prod.css"
    },
    {
      "replace": "src/app/login/login.component.html", // GOOD
      "with": "src/app/login/login.component.prod.html"
    },
    {
      "replace": "src/app/login/login.component.ts", // ERROR
      "with": "src/app/login/login.component.prod.ts"
    }
  ],

error:

ERROR in : Cannot determine the module for class LoginComponent in /src/app/login/login.component.prod.ts! Add LoginComponent to the NgModule to fix it.

I have this component header in "prod" and "normal" file.

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})

Is there a way to replace typescript file from component?

Alejandro L.
  • 1,066
  • 5
  • 17
  • 38
  • 1
    Maybe you need to add the `login.module.ts` as well to the file replacement and provide the correct declaration of the prod login component. If that does not work, maybe you can check the environment in your login component and change the behavior directly in there. – Marek W Oct 19 '20 at 09:57
  • 2
    somewhere in your modules under declarations you must have ```LoginComponent```. That file propably fails to import the component. Could be related to https://github.com/angular/angular-cli/issues/13964 – cpc Oct 19 '20 at 09:57
  • I have that declaration in `app.module.ts`, the error appears when I add the replace file option. – Alejandro L. Oct 19 '20 at 10:01

0 Answers0