Laravel Mix - Dependency was not found (for custom js file)

521 views Asked by At

I'm really fracking tired to struggle with mix thing.. really cannot understand what it is.

I just want to add a piece of script that needs to control my AJAX request. So here's what I do.

  1. I create custom file searchResource.js on resources\assets\js directory.
  2. Edit webpack.mix.js file before to after.

    // Before
    mix
        .js('resources/assets/js/app.js', 'public/js')
    
    // After
    mix
        .js([
            'resources/assets/js/app.js',
            'resources/assets/js/searchConcepts.js'
        ], 'public/js')
    
  3. On console, run npm run dev.

After this, I got Dependency was not found error and don't have a clue why/where do I specify dependencies for just simple script add.

After extensive search, I think there is something more has to be done but don't know what it is. Further, I believe I can't handle this. Need help..

1

There are 1 answers

0
GatesPlan On BEST ANSWER

Obviously, there is a reason why I can't mix things all together in app.js, but still don't know why. However, I've manage to do this anyway.

First, I should use .scripts() method and save my custom script to something like all.js, not app.js.

So, here is my answer.

mix
    .scripts('/resources/assets/js/ajaxAdaptor.js')
    .js('.. ')