2

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.

meblum
  • 1,654
  • 12
  • 23
  • check this out .. https://stackoverflow.com/questions/49851277/how-to-exclude-moment-locales-from-angular-build – maxkart Sep 29 '20 at 16:36
  • 1
    I am puzzled about the down vote: this is a perfectly good question. And not about slimming down the moment bundle by removing locales, but about removing `moment.js` completely – xverges Dec 04 '20 at 10:41

1 Answers1

0

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']
}
LeeLenalee
  • 27,463
  • 6
  • 45
  • 69