Search

Laravel URL Helper Function: elixir

November 21, 2016 —John Koster

elixir($file, $buildDirectory = 'build')

The elixir helper function can be used to get the path to a versioned Elixir file. The function accepts two arguments, the name of the $file to find the path for and the $buildDirectory to look in. By default, the $buildDirectory is set to build. The build directory is relative to the applications public directory (app/public).

Assuming the following simple gulpfile:

1var elixir = require('laravel-elixir');
2 
3elixir(function(mix) {
4 mix.sass('app.scss');
5 
6 // Version using the default configured build path.
7 mix.version('css/app.css');
8 
9 // Version using a custom build path.
10 mix.version('css/app.css', 'public/build2');
11});

The path to the file versioned using the default configured build directory can be determined like this:

1<?php
2 
3elixir('css/app.css');

and would produce output similar to the following:

1/build/css/app-aa3c9d985b.css

Likewise, the path to the versioned file with the custom build directory can be determined by supplying an argument for $buildDirectory:

1<?php
2 
3elixir('css/app.css', 'build2');

which would produce output similar to the following:

1/build2/css/app-64f4edce94.css

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.