Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elixir versioning public path

I'm trying to use Elixir's version() method with my 'public' folder being public_html (instead of the default 'public' method).

I version my css file, which produces a build folder with the manifest inside public_html

elixir.config.cssOutput = 'public_html/css';
elixir.config.jsOutput = 'public_html/js';

elixir(function(mix) {

    mix.styles([
        'vendor/normalize.css',
        'app.css'
    ], null, 'public_html/css');

    mix.version('public_html/css/all.css');

});

In my blade template I use

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

Problem is the elixir function searches in 'public/build' folder. How can I change this so it searches public_html folder?

Thank you in advance

like image 863
Gregory Avatar asked Apr 07 '15 07:04

Gregory


1 Answers

You forgot to overwrite your publicDir folder in the gulpfile.js file, this points the build folder to the correct location which is used by elixir to determine the version hash.

elixir.config.publicDir = 'public_html';

After you did that you must overwrite your public_path in Laravel, the recommended way for Laravel 5 is to go to the index.php in your public folder:

Underneath

$app = require_once __DIR__.'/../bootstrap/app.php';

Add

// set the public path to this directory
$app->bind('path.public', function() {
    return __DIR__;
});
like image 145
Maarten de Graaf Avatar answered Oct 06 '22 00:10

Maarten de Graaf