3
Good afternoon,
I am studying the Laravel 5.7 and was wanting to use a plugin called progressbar.js.
One of the ways to install the plugin, is by playing the file progressbar.js right in the public/js from Laravel, after that, I write where I want the effect to apply, ex:
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 the npm of node.js.
As per the plugin documentation, surround npm install progressbar.js(the installation is done successfully), after that I go to webpack.mix.js to use the laravel-mix of Laravel, I add what I want the laravel-mix copy for me on public of Laravel:
const mix = require('laravel-mix');
mix.js(...)
.js("node_modules/progressbar.js/dist/progressbar.js", 'public/js')
.sass(...);
Rodo the npm run dev, So far, ok! file copied to Laravel’s public successfully...
I’ll go in my file from app.blade.php add the script in the same place as the old one (that’s working), the one I think is right:
<script src="{{ asset('js/progressbar.js') }}" defer></script>
And that’s it! Mistake:
Uncaught ReferenceError: ProgressBar is not defined
at onLoad ((index):74)
onLoad @ (index):74
load (async)
(anonymous) @ (index):73
One thing I realized, after I used the laravel-mix the script gave a change, I do not know what influenced the change, but it was noted that influenced rsrs... Since the script is really big, I can’t 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
I’ve uploaded the project to Github so you can take a look... Github repository
run the following command and enter the result of the execution after that:
npm install progressbar.js -- save– Sorack
Hello buddy, did you import the Progressbar? Using:
var ProgressBar = require('progressbar.js');– MSLacerda
@Sorack Rodei, gave a modified code, I left the link to the Git repository for you to take a look...
– Ursones
@matheussoareslacerda gave the following msg "Uncaught Referenceerror: require is not defined at (index):108"
– Ursones