Question regarding bootstrap.js and requiring

Posted 2 years ago by Filip_Zdravkovic

I've installed Chart.js via npm:

npm install chart.js --save

After that, in resources/assets/js/bootstrap.js I added:


and after running the gulp command - everything works fine. My question is - what I am requiring with require('chart.js');?

npm install command installs JavaScript libraries and frameworks (dependencies) inside node_modules. Concretely, I see that now there is chart.js directory inside node_modules, and chart.js contains many other directories/files.

Now, I know that Chart.js provides two different builds that are available for use:

The Chart.js and Chart.min.js files include Chart.js and the accompanying color parsing library. If this version is used and you require the use of the time axis, Moment.js will need to be included before Chart.js. The Chart.bundle.js and Chart.bundle.min.js builds include Moment.js in a single file. This version should be used if you require time axes and want a single file to include, select this version. Do not use this build if your application already includes Moment.js. If you do, Moment.js will be included twice, increasing the page load time and potentially introducing version issues.

and I see that there are all of these builds (Chart.js, Chart.min.js, Chart.bundle.js and Chart.bundle.min.js) in the node_modules/chart.js/dist directory.

So, when I run gulp - which one of these will be used for generating a single bundled file in the public/js directory?

Please sign in or create an account to participate in this conversation.