Can anyone guide me on how to properly install and integrate [email protected] in my laravel application?
Currently, I am using cdn links, but I want to avoid that in the future.
List of cdn links being used:
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d5b6bdb4a7a1bfa6f8b6bdb4a7a1f8a1a7b0b0b8b4a595e5fbe7fbe6">[email protected]</a>"></script>
Approach I took:
- Installed chartjs package
npm i <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="96f5fef7e4e2b8fce5d6a4b8afb8a2">[email protected]</a>
- Added this line in webpack.mix.js file:
mix.copy('node_modules/chart.js/dist/chart.js', 'public/chart.js/chart.js');
- Executed this command in the terminal:
npm run dev
- Included the script tag in the blade where the chart will be displayed:
<script src="{{ asset('chart.js/chart.js') }}"></script>