This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Sprockets directive plugin (filter) for janmarek/webloader

0.2.3 2016-08-04 07:42 UTC

This package is not auto-updated.

Last update: 2021-07-24 02:06:53 UTC


Build Status Latest Stable Version Composer Downloads

This is a plugin for janmarek/webloader which adds availability to interpret sprockets directives in you Javascript and Coffeescript files. It is based on rafacgarciaa/php-lilo.

Lilo is a fast engine that allow you scan a file to extract a dependency graph using a subset of Sprockets directives. Following directives are supported:

//= require
//= require_directory
//= require_tree

For more information about them please visit Sprockets.

Usage (javascript)

In your javascript files, write Sprockets-style comments to indicate dependencies, e.g.

//= require ../bower_components/jquery/dist/jquery.js

If you want to bring in a whole folder of files, use

//= require_tree libs

Please note, that sprocket directives must be at the top of the javascript file!

//= require ../bower_components/jquery/dist/jquery.js

;(function($) {
  // your code


Installation (Webloader)

Install this package via Composer:

composer require srigi/webloader-require-filter

Configure Webloader to use filter:

    requireFilter: Srigi\Webloader\Filters\RequireFilter

                sourceDir: %wwwDir%/../assets/scripts
                joinFiles: not(%debugMode%)
                    - @requireFilter
                    - {files: ["*.js"], from: %wwwDir%/../assets/scripts}

By default webloader-require-filter works with Javascript files. You can also process Coffeescript files, just configure service:

    requireFilter: Srigi\Webloader\Filters\RequireFilter(['js', 'coffee'])

Currently webloader-require-filter seach dependencies in sourceDir of the processed file. Don't forget to setup sourceDir in your webloader configuration!


  • Lilo, a file concatenation tool for PHP inspired by Sprockets
  • Sprockets, Rack-based asset packaging system