Last active
December 18, 2015 03:18
-
-
Save rtablada/5716736 to your computer and use it in GitHub Desktop.
This is an idea for a Guard based Asset Pipeline for Laravel 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
/* | |
|-------------------------------------------------------------------------- | |
| Pipelines | |
|-------------------------------------------------------------------------- | |
| | |
| In this configuration, you will specify your asset pipelines, | |
| For each pipeline you can specify what files you want included in | |
| your final minified production file | |
| | |
*/ | |
'pipelines' => array( | |
'application' => array( | |
'styles' => array( | |
'lib/bootstrap.css', | |
'main.css' | |
), | |
'scripts' => array( | |
'lib/jquery.js' | |
) | |
), | |
), | |
/* | |
|-------------------------------------------------------------------------- | |
| The Path To Your Assets Directory | |
|-------------------------------------------------------------------------- | |
| | |
| Here, you'll specify where you want your assets directory to go. | |
| This will be the base directory, where sass, less, and coffee directories | |
| will be inserted. | |
| | |
*/ | |
'assets_path' => 'app/assets', | |
/* | |
|-------------------------------------------------------------------------- | |
| The Path To Your Coffeescript Assets | |
|-------------------------------------------------------------------------- | |
| | |
| This is an optional config in case you don't store your .coffee files | |
| in $asset_path . '/coffee/' | |
| | |
*/ | |
// 'coffee_assets_path' => 'app/assets/coffee', | |
/* | |
|-------------------------------------------------------------------------- | |
| The Path To Your Less Assets | |
|-------------------------------------------------------------------------- | |
| | |
| This is an optional config in case you don't store your .less files | |
| in $asset_path . '/less/' | |
| | |
*/ | |
// 'less_assets_path' => 'app/assets/less', | |
/* | |
|-------------------------------------------------------------------------- | |
| Your Compiled Assets Path | |
|-------------------------------------------------------------------------- | |
| | |
| This is the folder where your assets will be compiled to. | |
| This is where all of your assets will compile to and should not be used | |
| for minified production code. | |
| | |
*/ | |
'compile_dir' => 'public/src', | |
/* | |
|-------------------------------------------------------------------------- | |
| Your Compiled CSS Path | |
|-------------------------------------------------------------------------- | |
| | |
| This is an optional cofig in case you don't want your compiled CSS files | |
| in $compile_dir . '/css/' | |
| | |
*/ | |
// 'css_compile_dir' => 'public/src/css', | |
/* | |
|-------------------------------------------------------------------------- | |
| Your Compiled JS Path | |
|-------------------------------------------------------------------------- | |
| | |
| This is an optional cofig in case you don't want your compiled JS files | |
| in $compile_dir . '/js/' | |
| | |
*/ | |
// 'js_compile_dir' => 'public/src/js', | |
/* | |
|-------------------------------------------------------------------------- | |
| Your Production Folder | |
|-------------------------------------------------------------------------- | |
| | |
| This folder is the location where your minified and concatinated production | |
| files will be placed | |
| | |
*/ | |
'production_dir' => 'public/assets', | |
/* | |
|-------------------------------------------------------------------------- | |
| Your Production CSS Folder | |
|-------------------------------------------------------------------------- | |
| | |
| This optional config specifies the folder where your minified and | |
| concatinated CSS production files will be placed | |
| | |
*/ | |
'css_production_dir' => 'public/assets/css', | |
/* | |
|-------------------------------------------------------------------------- | |
| Your Production JS Folder | |
|-------------------------------------------------------------------------- | |
| | |
| This optional config specifies the folder where your minified and | |
| concatinated JS production files will be placed | |
| | |
*/ | |
'js_production_dir' => 'public/assets/js', | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/ | |
|-assets/ | |
| |-coffee/ | |
| | |-main.coffe | |
| |-less/ | |
| | |-main.less | |
public/ | |
|-assets | |
| |-css | |
| | |-application.css | |
| |-js | |
| | |-application.js | |
|-src | |
| |-css | |
| | |-lib/ | |
| | | |-bootstrap.css | |
| | |-main.css | |
| |-js | |
| | |-lib/ | |
| | | |-jquery.js | |
| | |-main.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard :coffeescript, :input => "app/assets/coffee", :output => "public/src/js" | |
guard :less, :all_on_start => true, :all_on_start => false, :output => 'public/src/css' do | |
watch(%r[^app/assets/less/(.+\.less)$]) | |
end | |
guard :concat, :type => "css", :files => %w[lib/bootstrap main], :input_dir => "public/src/css", :output => "public/assets/css/application" | |
guard :concat, :type => "js", :files => %w[lib/jquery main], :input_dir => "public/src/js", :output => "public/src/js/application" | |
# Refresh the browser on save | |
guard 'livereload' do | |
watch(%r{.+(?<!\.min)\.(css|html|js|blade\.php)$}) | |
end | |
guard :phpunit, :all_on_start => false, :tests_path => 'app/tests/', :cli => '--colors -c phpunit.xml' do | |
# Run any test in app/tests upon save. | |
watch(%r{^.+Test\.php$}) | |
# When a view file is updated, run tests. | |
# Tip: you probably only want to run your integration tests. | |
watch(%r{app/views/.+\.php}) { Dir.glob('app/tests/**/*.php') } | |
# When a file is edited, try to run its associated test. | |
# Save app/models/User.php, and it will run app/tests/models/UserTest.php | |
watch(%r{^app/(.+)/(.+)\.php$}) { |m| "app/tests/#{m[1]}/#{m[2]}Test.php"} | |
end | |
module ::Guard | |
class Refresher < Guard | |
def run_all | |
# refresh | |
end | |
def run_on_additions(paths) | |
refresh | |
end | |
def run_on_removals(paths) | |
refresh | |
end | |
def refresh | |
`php artisan guard:refresh` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment