0
votes

I am trying to create a component using command ng generate component test. but I didn't find module.ts file with this. What is the command that I can use instead? thanks.

2

2 Answers

0
votes

You can try to specify the --module=app param. Instead of app you can specify the module where you want to declare you new component.

You can also take a look the CMS schematics that Spartacus offers.

0
votes

I'm not 100% sure why you need another module - I have added a custom component to my Spartacus instance (using ng generate) without adding a new module and everything works fine.

For reference, I simply added the new component into my app.module.ts like so:

import { GigyaRaasComponent } from './gigya-raas/gigya-raas.component';

@NgModule({
  declarations: [
    AppComponent,
    GigyaRaasComponent
  ],
  imports: [
    BrowserModule,
    B2cStorefrontModule.withConfig({
      backend: {
        occ: {
          baseUrl: 'https://localhost:9002',
          prefix: '/rest/v2/'
        }
      },
      context: {
        baseSite: ['electronics-spa']
      },
      i18n: {
        resources: translations,
        chunks: translationChunksConfig,
        fallbackLang: 'en'
      },
      features: {
        level: '*',
        anonymousConsents: true
      },
      cmsComponents: {
        GigyaRaasComponent: {
          component: GigyaRaasComponent
        }
      }
    })
  ],
  providers: [],
  bootstrap: [AppComponent],
  entryComponents: [GigyaRaasComponent]
})