How to use the @spartacus/core.ConfigModule.withConfig function in @spartacus/core

To help you get started, we’ve selected a few @spartacus/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / lib / cms / cms.module.ts View on Github external
CmsConfig,
  CmsModule as CmsCoreModule,
  defaultCmsModuleConfig,
} from '@spartacus/core';

// guards
import { guards } from './guards/index';

import { OutletModule } from '../outlet/outlet.module';
import { OutletDirective } from '../outlet/outlet.directive';

@NgModule({
  imports: [
    CommonModule,
    HttpClientModule,
    ConfigModule.withConfig(defaultCmsModuleConfig),
    OutletModule,
    CmsCoreModule,
  ],
  providers: [...guards, { provide: CmsConfig, useExisting: Config }],
  declarations: [],
  exports: [OutletDirective],
})
export class CmsModule {}
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / lib / ui / pages / pages.module.ts View on Github external
PageLayoutModule,
} from '../../../cms-structure/page/index';
import { CartPageModule } from './cart-page/cart-page.module';
import { OrderConfirmationPageModule } from './order-confirmation-page/order-confirmation-page.module';
import { ProductPageModule } from './product-page/product-page.module';
import { defaultRoutingConfig } from './default-routing-config';

const pageModules = [
  CartPageModule,
  OrderConfirmationPageModule,
  ProductPageModule,
];

@NgModule({
  imports: [
    ConfigModule.withConfig(defaultRoutingConfig),
    CommonModule,
    ...pageModules,
    PageLayoutModule,
    RouterModule.forChild([
      {
        // This route can be dropped only when we have a mapping path to page label for content pages
        path: null,
        canActivate: [CmsPageGuard],
        component: PageLayoutComponent,
        data: { pageLabel: 'homepage', cxRoute: 'home' },
      },
      {
        path: null,
        canActivate: [LogoutGuard],
        component: PageLayoutComponent,
        data: { cxRoute: 'logout' },
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-structure / pwa / pwa.module.ts View on Github external
export function pwaConfigurationFactory(
  pwaConfig: PWAModuleConfig
): SwRegistrationOptions {
  return { enabled: (!isDevMode() && pwaConfig.pwa.enabled) || false };
}

export function pwaFactory(addToHomeScreenService): any {
  const result = () => addToHomeScreenService;
  return result;
}

@NgModule({
  imports: [
    CommonModule,
    ConfigModule.withConfig(defaultPWAModuleConfig),
    ServiceWorkerModule.register('/ngsw-worker.js'),
    I18nModule,
  ],
  providers: [
    { provide: PWAModuleConfig, useExisting: Config },
    {
      provide: SwRegistrationOptions,
      useFactory: pwaConfigurationFactory,
      deps: [Config],
    },
    {
      provide: APP_INITIALIZER,
      useFactory: pwaFactory,
      deps: [AddToHomeScreenService],
      multi: true,
    },
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / misc / icon / icon.module.ts View on Github external
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { Config, ConfigModule } from '@spartacus/core';
import { fontawesomeIconConfig } from './fontawesome-icon.config';
import { IconComponent } from './icon.component';
import { IconConfig } from './icon.model';

@NgModule({
  declarations: [IconComponent],
  imports: [CommonModule, ConfigModule.withConfig(fontawesomeIconConfig)],
  providers: [{ provide: IconConfig, useExisting: Config }],
  exports: [IconComponent],
})
export class IconModule {}
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / cms-components / content / banner-carousel / banner-carousel.module.ts View on Github external
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { CmsConfig, ConfigModule } from '@spartacus/core';
import { PageComponentModule } from '../../../cms-structure/page/index';
import { CarouselModule, MediaModule } from '../../../shared/components/index';
import { BannerCarouselComponent } from './banner-carousel.component';

@NgModule({
  imports: [
    CommonModule,
    ConfigModule.withConfig({
      cmsComponents: {
        RotatingImagesComponent: {
          component: BannerCarouselComponent,
        },
      },
    } as CmsConfig),
    PageComponentModule,
    CarouselModule,
    MediaModule,
  ],
  declarations: [BannerCarouselComponent],
  entryComponents: [BannerCarouselComponent],
  exports: [BannerCarouselComponent],
})
export class BannerCarouselModule {}
github SAP / cloud-commerce-spartacus-storefront / projects / vendor / src / yotpo / yotpo.module.ts View on Github external
import { NgModule } from '@angular/core';
import { Config, ConfigModule } from '@spartacus/core';
import { CommonModule } from '@angular/common';
import { YotporeviewComponent } from './yotporeview/yotpo-review.component';
import { YotpostarratingComponent } from './yotpostarrating/yotpo-star-rating.component';
import { YotpoConfig } from './yotpoconfig/yotpo-config';
import { defaultYotpoConfig } from './yotpoconfig/default-yotpo-config';

@NgModule({
  imports: [CommonModule, ConfigModule.withConfig(defaultYotpoConfig)],
  exports: [YotporeviewComponent, YotpostarratingComponent],
  declarations: [YotporeviewComponent, YotpostarratingComponent],
  entryComponents: [YotporeviewComponent, YotpostarratingComponent],
  providers: [{ provide: YotpoConfig, useExisting: Config }],
})
export class YotpoModule {}
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / lib / ui / layout / layout.module.ts View on Github external
import { NgModule } from '@angular/core';
import { Config, ConfigModule } from '@spartacus/core';
import { OutletRefModule } from '../../outlet/index';
import { StyleRefModule } from '../../outlet/style-ref/style-ref.module';
import { BreakpointService } from './breakpoint/breakpoint.service';
import { defaultLayoutConfig } from './config/default-layout-config';
import { LayoutConfig } from './config/layout-config';
import { MainModule } from './main/main.module';

const layoutModules = [OutletRefModule, StyleRefModule];

@NgModule({
  imports: [
    MainModule,
    ...layoutModules,
    ConfigModule.withConfig(defaultLayoutConfig),
  ],
  providers: [
    { provide: LayoutConfig, useExisting: Config },
    BreakpointService,
  ],
  exports: [MainModule, ...layoutModules],
})
export class LayoutModule {}
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / layout / a11y / skip-link / skip-link.module.ts View on Github external
ComponentFactoryResolver,
  NgModule,
} from '@angular/core';
import { Config, ConfigModule, I18nModule } from '@spartacus/core';
import {
  OutletPosition,
  OutletService,
} from 'projects/storefrontlib/src/cms-structure';
import { defaultSkipLinkConfig, SkipLinkConfig } from './config';
import { SkipLinkComponent } from './component/skip-link.component';

@NgModule({
  imports: [
    CommonModule,
    I18nModule,
    ConfigModule.withConfig(defaultSkipLinkConfig),
  ],
  declarations: [SkipLinkComponent],
  entryComponents: [SkipLinkComponent],

  providers: [
    { provide: SkipLinkConfig, useExisting: Config },
    {
      provide: APP_INITIALIZER,
      useFactory: skipLinkFactory,
      deps: [ComponentFactoryResolver, OutletService],
      multi: true,
    },
  ],
})
export class SkipLinkModule {}