Skip to content

How to load via Laravel Mix? #287

Answered by Synchro
Synchro asked this question in Q&A
Sep 23, 2021 · 4 comments · 1 reply
Discussion options

You must be logged in to vote

I've come to the conclusion that you can't use mix except as a means of copying files into place separately, like this:

mix.copy(
    [
        'node_modules/chart.js/dist/chart.js'
    ],
    'public/js/chart.js'
);
mix.copy(
    [
        'node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.js'
    ],
    'public/js/chartdatalabels.js'
);

and then loading each script from a separate scrip tag.

Combining the files stops it working, so don't do that.

When I use this approach I don't seem to need to do any of the registration steps described in the docs as both Chart and ChartDataLabels are immediately available in the global scope. I don't understand why this simple appr…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@LeeLenaleee
Comment options

Answer selected by Synchro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #280 on October 08, 2021 09:17.