Good afternoon,
I'm studying Laravel 5.7 and was looking to use a plugin called progressbar.js .
One of the ways to install the plugin is to play the file progressbar.js
direct in public/js
of Laravel, after that, I write where I want the effect to apply, eg:
var bar = new ProgressBar.Path('#LoadingDiv', {
easing: 'easeInOut',
duration: 2400
});
bar.set(0);
bar.animate(1.0); // Number from 0.0 to 1.0
And the effect test works normally ...
But I think this is not a good practice, so I decided to appeal to npm
of node.js
.
According to the plugin's documentation, I circled npm install progressbar.js
(the installation is done successfully), after that I go to webpack.mix.js
to use laravel-mix
of Laravel, add what I want laravel-mix
to copy to min no public
of Laravel:
const mix = require('laravel-mix');
mix.js(...)
.js("node_modules/progressbar.js/dist/progressbar.js", 'public/js')
.sass(...);
Rodo npm run dev
, so far, okay! file copied to Laravel's public successfully ...
I'll add my script to the same file as the old one (which is working), as I think it is correct:
<script src="{{ asset('js/progressbar.js') }}" defer></script>
And that's it! Error:
Uncaught ReferenceError: ProgressBar is not defined
at onLoad ((index):74)
onLoad @ (index):74
load (async)
(anonymous) @ (index):73
One thing I noticed is that after I used app.blade.php
the script changed, I do not know what influenced the change, but I noticed that it influenced rsrs ... Since the script is pretty big, I can not display it here for you ...
Well, does anyone know what I'm doing wrong? I think I'm doing something wrong in the process ...
Edit
Upload the project to GitHub so you can take a look ... GitHub Repository