simplette/loader

Loader for styles and scripts.

v0.1.0 2019-09-13 13:56 UTC

This package is auto-updated.

Last update: 2024-12-14 04:16:07 UTC


README

An implementation of simple assets loader - for building your styles and javascripts on the fly. Thank to this library, you can simplify your workflow with Nette Framework's frontend.

Requirements

This library requires PHP 7.1 or higher. Simplette Loader library is designed for Nette Framework version 3.0 and higher.

Installation

The best way to install this library is using Composer:

$ composer require simplette/loader

Documentation

Firstly, register extensions. For more information about configuration see the class definition. This library (as all libraries from Simplette) is meant to be as simple as possible.

extensions:
    style: Simplette\Loader\Style\StyleLoaderExtension
    script: Simplette\Loader\Script\ScriptLoaderExtension

Now you can define your own list of styles, scripts, configure each part of loader, etc.

See example configuration:

style:
    debugger: %debugMode% # or just set true/false
    genDir: assets/gen
    files:
        admin-sb: # you can combine scss and css files
            - %appDir%/Modules/AdminModule/styles/admin-sb.scss
            - %appDir%/Modules/AdminModule/styles/daterangepicker.css
        admin-editor:
            - %appDir%/Modules/AdminModule/styles/codemirror.css
            - %appDir%/Modules/AdminModule/scripts/vendor/codemirror/addon/display/fullscreen.css
            - %appDir%/Modules/AdminModule/styles/codemirror.scss
        # ...

script:
    debugger: %debugMode%
    compiler:
        minify: FALSE # turn off minification / there can be possible to set other compiler parameters
    genDir: assets/gen
    files:
        admin-sb:
            - %appDir%/Modules/AdminModule/scripts/vendor/bootstrap.bundle.min.js # files *.min.* would not be minified again 
            # ...
            - %appDir%/Modules/AdminModule/scripts/sb-admin-2.js
            # ...
        admin-search:
            # ...
            - %appDir%/Modules/AdminModule/scripts/search.js
        admin-nette:
            - %appDir%/../vendor/nette/forms/src/assets/netteForms.min.js
            - %appDir%/Modules/AdminModule/scripts/vendor/nette.ajax.js
            # ...
            - %appDir%/Modules/AdminModule/scripts/init-nette.js
        admin-editor:
            - %appDir%/Modules/AdminModule/scripts/vendor/codemirror/codemirror.js
            # ...
            - %appDir%/Modules/AdminModule/scripts/init-editor.js
        # ...

Then you can use it in your latte templates like this:

<link rel="stylesheet" n:style="admin-sb"/>

<script n:script="admin-sb"></script>

Contributing

This is an open source, community-driven project. If you would like to contribute, please follow the code format as used in current sources and submit a pull request.

Advanced documentation will be added in the future. But if you look on my source codes, you will understand what you can do with this small (but powerful) library.

See also other libraries and some older work if you are looking for inspiration.