ffritz
ffritz

Reputation: 2261

vue-cli build not using minified versions of libraries

I am trying to reduce the size of my SPA build, which gets build using vue-cli build. I am using Chart.js and after building the application, I ran webpack-bundle-analyzer and it shows Chart.js with it's full size, and not chart.min.js.

enter image description here

What I am expecting is that it would use /dist/chart.min.js. I am not understanding this correctly, or is it actually using the non-minified file?

Upvotes: 2

Views: 391

Answers (1)

ffritz
ffritz

Reputation: 2261

I got around to having another look at this and this is simply because vue-chartjs needs chart.js as peer dependency and is thus not taking care of anything in my side of the build step.

Related: https://github.com/apertureless/vue-chartjs/issues/249

The fix is to configure it accordingly in the webpack config:

        resolve: {
            alias: {
                'chart.js$': 'chart.js/dist/Chart.min.js',
            },
        },

Upvotes: 1

Related Questions