Search code examples
phplaravel-5laravel-elixir

laravel elixir script not building when compiled


Folder Tree

enter image description here

Gulp.js

var elixir = require('laravel-elixir');

elixir(function(mix) {

mix.sass('app.scss')
   .script('app.js')
   .version( ['css/app.css','js/app.js']);

});

Why is script not building and doesn't create js folder in public/build and not even added in rev-manifest.json? that's why when i call it to my Html, it throw's an error: "File js/app.js not defined in asset manifest".

HTML

<script type="text/javascript" src="{{ elixir('js/app.js') }}"></script>

Solution

  • The scripts (plural) method assumes all paths are relative to the resources/assets/js directory, and will place the resulting JavaScript in public/js/all.js by default. If you need to change the destination folder you can use the second parameter:

    .scripts(['app.js'], 'public/build/js/app.js')
    

    I hope this will help you.