Search code examples
laravel-5laravel-elixir

Laravel 5 Elixir source and output pathing


I'm having trouble understanding Laravel 5's elixir pathing. In my project, I have multiple css files (bootstrap, plugins, theme etc) and javascript files stored under:

resources/assets/css/<my css files>
resources/assets/js/<my javascript files>

I simply want to combine and version all styles and scripts and place them in my public directory. I believe the default output directly is:

public/build/css/app-xxxxxxxx.css
public/build/js/app-xxxxxxxx.js

(Where xxxxxxxx is the checksum using the version method)

What should my gulpfile.js look like to achieve this? Thanks!


Solution

  • You can use full path on the name or set the third parameter as default path. Examples (works with scripts or css):

    mix.stylesIn('resources/assets/css', 'public/css/all.css');
    

    Since there is a bug where you can't use the output of a somethingAll to concatenate with something else, I use this instead (note the wildcard):

    mix.scripts(['maskedinput.js',
            'blockui.js',
            'user/*.js'],
       'public/js/user.js', 'resources/assets/js/');
    

    First parameter is the input files, second is the output file, third is the input's default path.

    To version just call it on the file path.

    mix.version("public/js/user.js");