0

Its always nice to use Laravel elixir feature. But I have some basic question. Firstly when we run gulp command, it concatenates all the css and js files. But I think I dont need, for example, datatables.css and datatables.js/boostrap-wysihtml for all of my pages. how to tackle this situation?

Secondly Lets review this code:

elixir(function(mix) {

    mix.styles([
      "bootstrap.min.css",
      "owl.carousel.css",
      "animate.css",
      "style.css",
      "datepicker.css"
    ]);

    mix.scripts([
      "jquery.min.js",
      "bootstrap.min.js",
      "bootstrap-datepicker.js",
      "typed.min.js",
      "wow.min.js",
      "owl.carousel.min.js",
      "home.js",
      "side-navigation.js",
      "script.js"
    ]);

    mix.version(["css/all.css","js/all.js"]);
});

in blade:

<link rel="stylesheet" href="{{ url(elixir('css/all.css')) }}">

what is the use of this elixir() function, when we are creating all.js and all.css file that has everything concatenated inside it?

Noob Coder
  • 2,816
  • 8
  • 36
  • 61
  • 1
    I have answered a very similar question [here](http://stackoverflow.com/questions/35135525/elixir-gulp-laravel-with-differents-js-inclusions-depending-on-url/35136313#35136313) which if you read, might help show you the answer to your question about including only what is needed in your `elixir` files. – camelCase Jun 02 '16 at 19:42

1 Answers1

0

You want to use the elixir function in the blade template because it will automatically use the rev.manifest file to resolve which versioned file(s) to use. The docs have more info. As far as not needing all scripts on all pages, there are a few different ways to pull it off. You can create a task that generates just generates one bundle - perhaps scripts needed everywhere - and another bundle handling the rest. I'd advise you to research that to see what works best for you.

patricksweeney
  • 3,939
  • 7
  • 41
  • 54