I have a problem with webpack.mix in laravel, my modules are not being recognized, i did some research for figuring out what could be happening:
- simple way to include node_modules in laravel 5.5
- installing JS packages using npm and compiling with webpack laravel mix
- How to include webpack plugins when using Laravel Mix?
This is my app.js file from resources/assets/js
console.log('Test');
require('imagesloaded')
require('jquery')
require('slick-carousel')
In the console i see 'Test', but all the other modules are not recognized, in public/js i have the init files for each module but is not working, i even try this in webpack.mix.js:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.extract([
'jquery',
'slick-carousel',
'imagesloaded'
])
.options({
uglify: true,
})
And importing vendor.js.
I also tried initializing the modules in the app.js file, for initializing i mean just slick(), i also tried giving each require a variable name, and using syntax import "modulename", but nothing...
Any ideas of what could be happening?
After some trial and error with DigitalDrifer this is the app.js file working
import $ from 'jquery'
const imagesLoaded = require('imagesloaded')
const slick = require('slick-carousel')
With all the code for initializing each package inside app.js (below requiring), not in different folders, according to this that is a bad practice anyways.