Remove moment from chartjs in angular app

686 views Asked by At

I am using ng2-charts in my project, it is basically just a wrapper over chart.js so I have to install chart.js as well. According to the chart.js docs, moment is included by default in the build, and must be excluded by configuring webpack. Is there a way to configure the build in an angular application? Or some other way to exclude moment? Note, I am not using chart.js directly, it is used by the ng2-charts lib.

1

There are 1 answers

0
LeeLenalee On BEST ANSWER

In the upcomming release (V3) of the ng2-charts lib which uses Chart.js V3 it is not pressent anymore by default.

According to the documentation of chart.js itself you can remove moment like so:

// Webpack
{
    externals: {
        moment: 'moment'
    }
}

// Rollup
{
    external: ['moment']
}