Coding my way

2 years ago in Javascript, Laravel · 1 MIN READ

Configuring Laravel Elixir

Jeffrey Way created something which I think is a bit under appreciated. Elixir is a great tool which immensely helps set up a workflow for your Front-end application by boilerplating many Gulp tasks. It's not Laravel exclusive, so you can use all of it outside Laravel for other projects as well!

But, while it's pure greatness, some things are lacking... a proper documentation for starters. The one at Laravel's documentation is good enough to get you started using it, but lacks on how to fine tune it.

Thankfully it's not a great deal to modify the settings for the gulp utilities included with Elixir. As always, there are more ways to approach this.

The Direct route

You can edit the configuration directly in your Gulpfile.js, here's an example:

elixir.config.css.autoprefix = {
    enabled: true,

    options:  {
        browsers: ['> 5%'],
        cascade: false

Just use this before your first task and you should be fine.

One more NPM Package

In the olden days (before v6.0.0-11) there was an option to create an elixir.json file and store your configuration there, but support for this has been removed, hence the community to the rescue! There's a package called laravel-elixir-config on NPM that restores the elixir.json functionality. You can read more about it on the package's NPM page

Great, but what are my options?

As always, you can find out your options several ways. One would be to check out the Config.js file in Elixir's source. Another would be to console.log(elixir.config) before your first task.


Miklós Galicz

I'm a hobbyist who managed to become a professional web developer who specializes in Laravel and Vue.js, also the Spice must flow.
comments powered by Disqus

© 2019 DevBlog