geniv/nette-front-loader

Front loader extension for Nette Framework

v1.1.8 2018-07-12 14:14 UTC

README

for CSS & JS loader

Installation

$ composer require geniv/nette-front-loader

or

"geniv/nette-front-loader": ">=1.0.0"

require:

"php": ">=5.6.0",
"nette/nette": ">=2.4.0"

Include in application

neon configure:

# front loader
frontLoader:
#   debugger: false
#   productionMode: true
#   developmentMode: false
    dir: %wwwDir%
    css:	# files without extension
        - css/global
        - static:css/global1
        - "https://fonts.googleapis.com"
        front:  # source
            - css/styles1
            - static:css/styles2
    js:		# files without extension
        - js/global
        - static:js/global1
        - "https://cdnjs.com"
        front:  # source
            - js/script1
            - static:js/script2
    tagDev: '.'
    tagProd: '.min.'
    envDev: 'development'
    envProd: 'production'
    modifyTimeVar: 'mt'
    indentation: "    "
#   indentation:
#       css: "    "
#       js: "  "
    compile:
        inputDir: %wwwDir%/../vendor/geniv
        outputFileScss: %wwwDir%/../assets/scss/vendors/composer-components/composer-components.scss
        outputFileJs: %wwwDir%/../assets/js/composer-components.js
        exclude:
            - CookieBar.scss
            - CookieBar.js

if productionMode is not defined or set null then loader will be automatic detect production mode

developmet or stage environment is development (tagDev) settings (full css).

production environment is production (tagProd) settings (minimal css).

compile block work only developmentMode, other accept: productionMode.

Setting for load css/js file without change environment name begin keyword: static: like http.

each mode states:

  • development:

    • productionMode: false
    • developmentMode: true
  • stage:

    • productionMode: false
    • developmentMode: false
  • production:

    • productionMode: true
    • developmentMode: false

neon configure extension:

extensions:
    frontLoader: FrontLoader\Bridges\Nette\Extension

usage:

use FrontLoader\FrontLoader;

protected function createComponentFrontLoader(FrontLoader $frontLoader)
{
    return $frontLoader;
}

@layout.latte

for CSS

{block head}
    {control frontLoader:css}
{/block}

or defined source

{block head}
    {control frontLoader:css 'front'}
{/block}

for JS

{block scripts}
    {control frontLoader:js}
{/block}

or defined source

{block scripts}
    {control frontLoader:js 'front'}
{/block}

other presenter *.latte:

{block title}...{/block}
{block description}...{/block}
{block slug}...{/block}

{block content}
...
{/block}

{block scripts}
    {include parent}
    <script src="source.js"></script>
{/block}

{block head}
    {include parent}
    <link rel="stylesheet" href="source.css">
{/block}