2017 © Pedro Peláez
 

library laravel-assets

A super simple script and stylesheet management package for Laravel 4.

image

blevins/laravel-assets

A super simple script and stylesheet management package for Laravel 4.

  • Tuesday, March 18, 2014
  • by graham
  • Repository
  • 2 Watchers
  • 3 Stars
  • 107 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Laravel 4 Asset Management

A super simple external JavaScript and Stylesheet management package for Laravel 4., (*1)

Installation

Add the package dependency to your project's composer.json file., (*2)

"require": {
    "laravel/framework": "4.1.*",
    "blevins/laravel-assets": "dev-master"
},

Run composer update and add 'Blevins\Assets\AssetsServiceProvider' to the app/config/app.php service providers array., (*3)

Configuration

Add an assets.php to your app/config directory. Specify environment configurations by adding an assets.php to each environment directory in your app/config directory., (*4)

There is no limit to the number of stylesheets or external scriptd. At least one media type is required as a key in the styles array., (*5)

<?php

return array(

    'scripts' => array(
        '/path/to/script/file-1.js',
        '/path/to/script/file-2.js',
        [ ..., ]
    ),

    'styles' => array(
        'all' => array(
            '/path/to/stylesheet/file-1.js',
            'foo' => '/path/to/stylesheet/file-2.js',
            [ ..., ]
        ),
        'screen' => array(
            '/path/to/stylesheet/file-3.js',
            [ ..., ]
        ),
        'print' => array(
            '/path/to/stylesheet/file-4.js',
            [ ..., ]
        ),
    ),
);

The following example includes all stylesheets and scrtips defined in assets.php., (*6)

<html>
    <head>
        {{ styles() }}
        {{ scripts() }}
    </head>
</html>
<html>
    <head>
        <link media="all" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-1.js">
        <link media="all" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-2.js">
        <link media="screen" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-3.js">
        <link media="print" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-4.js">
        <script src="/path/to/script/file-1.js"></script>
        <script src="/path/to/script/file-2.js"></script>
    </head>
</html>

But what if you need specific stylesheets or combination of stylesheets for different templates? The next example shows how to use the media type and dot notation to include specific stylesheets., (*7)

<html>
    <head>
        {{ styles(array('all.foo', 'print')) }}
    </head>
</html>
<html>
    <head>
        <link media="all" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-2.js">
        <link media="print" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-4.js">
    </head>
</html>

Example

Local: app/local/assets.php, (*8)

<?php

return array(

    'scripts' => array(
        '/assets/libs/requirejs/require.js',
        '/assets/core/lib/main.js',
    ),

    'styles' => array(
        'screen' => array(
            '/assets/core/css/style.css',
        ),
    ),
);

Default: app\assets.php, (*9)

<?php

return array(

    'scripts' => array(
        '/assets/build/lib/main.js',
    ),

    'styles' => array(
        'screen' => array(
            '/assets/build/css/style.css',
        ),
    ),
);

The Versions

18/03 2014

dev-master

9999999-dev

A super simple script and stylesheet management package for Laravel 4.

  Sources   Download

The Requires

 

by Graham Blevins

laravel css javascript assets

05/12 2013

0.1.4

0.1.4.0

A super simple script and stylesheet management package for Laravel 4.

  Sources   Download

The Requires

 

by Graham Blevins

laravel css javascript assets

05/12 2013

0.1.3

0.1.3.0

A super simple script and stylesheet management package for Laravel 4.

  Sources   Download

The Requires

 

by Graham Blevins

laravel assets

05/12 2013

0.1.2

0.1.2.0

A super simple script and stylesheet management package for Laravel 4.

  Sources   Download

The Requires

 

by Graham Blevins

laravel assets

05/12 2013

0.1.1

0.1.1.0

  Sources   Download

The Requires

 

by Graham Blevins

laravel

27/11 2013

0.1.0

0.1.0.0

  Sources   Download

The Requires

 

by Graham Blevins

laravel