Framework: elixir versioning does not respect subfolders

Created on 27 Jul 2015  路  3Comments  路  Source: laravel/framework

When laravel app is in subfolder of domain and assets are versioned via elixir's .version() worker then elixir helper doesn't respect subfolder. It just returns plain /build/ path:

https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/helpers.php#L691

Most helpful comment

I have just made a workaround - nest the elixir helper into asset in Blade this way:
{{ asset(elixir('css/style.css')) }}
It works for me

All 3 comments

Unfortunately this was already brought up here https://github.com/laravel/framework/issues/8565 and the response was basically that you shouldn't install Laravel in a subdirectory. Sometimes that's not always an option, e.g. my company doesn't want to generate a new subdomain for our staging server for each new app we make, so I'm forced to not use version() in any of my projects.

I also think elixir() should generate a path relative to the app root for consistency with Laravel's other helpers e.g. asset(), but it's not my decision.

FYI it was changed for Laravel 5.2 to use the asset() helper: #9552
(This can't be changed for 5.1 since it's a breaking change)

For a workaround until then, just add your own elixir() helper function that uses asset()

I have just made a workaround - nest the elixir helper into asset in Blade this way:
{{ asset(elixir('css/style.css')) }}
It works for me

Was this page helpful?
0 / 5 - 0 ratings