Coder Social home page Coder Social logo

laravel-assets's Introduction

Laravel Assets management

Latest Version Software License Quality Score StyleCI Total Downloads Maintainability

Installation

composer require botble/assets

For version <= 5.4:

Add to section providers of config/app.php:

// config/app.php
'providers' => [
    ...
    Botble\Assets\Providers\AssetsServiceProvider::class,
];

And add to aliases section:

// config/app.php
'aliases' => [
    ...
    'Assets' => Botble\Assets\Facades\AssetsFacade::class,
];

All assets resource will be manage in config file so we need to publish config to use.

php artisan vendor:publish --provider="Botble\Assets\Providers\AssetsServiceProvider" --tag=config

Add to your master layout view, in head tag:

{!! \Assets::renderHeader() !!}

and before body tag close:

{!! \Assets::renderFooter() !!}

Methods

Add scripts

\Assets::addScripts(['key-of-assets-in-config-file']);

Example:

\Assets::addScripts(['app', 'bootstrap', 'jquery']);

Add styles

\Assets::addStyles(['key-of-assets-in-config-file']);

Example:

\Assets::addStyles(['bootstrap', 'font-awesome']);

Remove scripts

\Assets::removeScripts(['key-of-assets-in-config-file']);

Example:

\Assets::removeScripts(['bootstrap']);

Remove styles

\Assets::removeStyles(['key-of-assets-in-config-file']);

Example:

\Assets::removeStyles(['font-awesome']);

Others

  • Set version for assets. Add to .env
ASSETS_VERSION=1.0

Then all assets will be added ?v=1.0

  • Change to online mode
ASSETS_OFFLINE=false

Then assets will be loaded from CDN if it's defined in config file.

  • To disable versioning:
ASSETS_ENABLE_VERSION=false

Contributors

License

MIT © Sang Nguyen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.