Avoid loading of all locales in fullcalendar

Discussão em 'Angular' iniciado por Mahesh Reddy, Março 15, 2025.

  1. Mahesh Reddy

    Mahesh Reddy Guest

    Assume I had variable where the required locales are dynamically getting update here in the below code i names it as requiedLocales, I want only them to be bundled in the build?

    only bundle the locales present in the requriedLocales Array

    import { Component, OnInit, inject } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { FullCalendarModule } from '@fullcalendar/angular';
    import dayGridPlugin from '@fullcalendar/daygrid';
    import allLocales from '@fullcalendar/core/locales-all'
    import { LocalizationService } from '../../services/localization.service';

    @Component({
    selector: 'app-calendar',
    standalone: true,
    imports: [CommonModule, FullCalendarModule],
    template: `
    <full-calendar [options]="calendarOptions"></full-calendar>
    `,
    })
    export class CalendarComponent implements OnInit {
    private localizationService = inject(LocalizationService);

    private requiredLocales = ['en','ja'];
    calendarOptions: any = {
    plugins: [dayGridPlugin],
    initialView: 'dayGridMonth',
    locales: allLocales,
    locale: 'en'
    };

    ngOnInit() {
    this.localizationService.language$.subscribe((lang) => {
    this.calendarOptions = { ...this.calendarOptions, locale: lang };
    });
    }
    }


    I had option to import only required and keep in locales(calendar options) array this works but doesn't suits my scenario so help me with other solutions like adding any webpack plugin ? or ?

    Continue reading...

Compartilhe esta Página