2017 © Pedro Peláez
 

library assets

Vegas CMF Assets

image

vegas-cmf/assets

Vegas CMF Assets

  • Wednesday, February 8, 2017
  • by vegas
  • Repository
  • 10 Watchers
  • 0 Stars
  • 165 Installations
  • JavaScript
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

Vegas CMF Assets

To provide easiness of maintaining assets we prepared grunt and gulp tasks which allow you to download all dependencies from vendor directory. We have specified unique name - vegas.json - to store project's dependencies (and their overrides) in external libraries., (*1)

Example vegas.json

{
    "dependencies": {
        "bootstrap": "3.1.0"
    },
    "exportsOverride": {
        "bootstrap": {
            "js": [
                "dist/js/*.js",
                "dist/js/*.map"
            ],
            "css": [
                "dist/css/*.css",
                "dist/css/*.map"
            ],
            "fonts": "dist/fonts/*.*"
        }
    }

}

Requirements

Grunt

$ npm install --global grunt-cli

Gulp

If you have previously installed a version of gulp globally, please run npm rm --global gulp to make sure your old version doesn't collide with gulp-cli., (*2)

$ npm install --global gulp-cli

Basic setup

Add the following script commands to your composer.json file, (*3)

Grunt commands:

"scripts": {
    "post-install-cmd": [
        "cp -n ./vendor/vegas-cmf/assets/Gruntfile.js ./Gruntfile.js",
        "cp -n ./vendor/vegas-cmf/assets/grunt_package.json ./package.json",
        "cp -n ./vendor/vegas-cmf/assets/bower.json ./bower_base.json"
    ],
    "post-update-cmd": [
        "cp -n ./vendor/vegas-cmf/assets/Gruntfile.js ./Gruntfile.js || true",
        "cp -n ./vendor/vegas-cmf/assets/grunt_package.json ./package.json || true",
        "cp -n ./vendor/vegas-cmf/assets/bower.json ./bower_base.json || true"
    ]
}

Gulp commands:

"scripts": {

    "post-install-cmd": [
        "cp -n ./vendor/vegas-cmf/assets/gulpfile.js ./gulpfile.js",
        "cp -n ./vendor/vegas-cmf/assets/gulp_package.json ./package.json",
        "cp -n ./vendor/vegas-cmf/assets/bower.json ./bower_base.json"
    ],
    "post-update-cmd": [
        "cp -n ./vendor/vegas-cmf/assets/gulpfile.js ./gulpfile.js || true",
        "cp -n ./vendor/vegas-cmf/assets/gulp_package.json ./package.json || true",
        "cp -n ./vendor/vegas-cmf/assets/bower.json ./bower_base.json || true"
    ]
}

Run composer update or install command, (*4)

php composer.phar update

Install NPM packages, (*5)

npm install

Note: Use sudo in case of permission problems, (*6)

Run

Merge all assets to bower file and run bower install by a simple shell command, (*7)

grunt

or:, (*8)

gulp

Custom options

You can also run bower install or bower update task without merging assets from vendor. For grunt:, (*9)

grunt bower:update // update

grunt bower:install // install

For gulp:, (*10)

gulp bower

Vegas CMF Assets Manager

Within this package, an assets container has been delivered, it's based on Phalcon's one. Assets Manager allows you to easily add resources like JS scripts, CSS styles etc. To use this feature, please create shared service in your Vegas project, as follows:, (*11)

namespace App\Shared;

use Vegas\Di\Injector\SharedServiceProviderInterface;

class AssetsManager implements SharedServiceProviderInterface
{
    /**
     * @return string
     */
    public function getName()
    {
        return 'assets';
    }

    /**
     * @param \Phalcon\DiInterface $di
     * @return mixed
     */
    public function getProvider(\Phalcon\DiInterface $di)
    {
        return function() use ($di)
        {
            return new Vegas\Assets\Manager();
        };
    }
}

From this point, you will have a possibilty to invoke Manager methods, by following syntax:, (*12)

// output JS files path
{{ assets.outputJs() }}

// output CSS files path
{{ assets.outputCss() }}

// add JS file to assets container
{{ assets.addJs('some/valid/path/to/js/file.js') }}

// add CSS file to assets container
{{ assets.addCss('some/valid/path/to/css/file.css') }}

Note

Keep it in mind, that config.php file must be updated too., (*13)

'sharedServices' => [
    ...
    'App\Shared\AssetsManager'
]

The Versions

08/02 2017

dev-master

9999999-dev

Vegas CMF Assets

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amsterdam Standard Vegas Team

08/02 2017

v3.0

3.0.0.0

Vegas CMF Assets

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amsterdam Standard Vegas Team

20/05 2016

1.2.x-dev

1.2.9999999.9999999-dev

Vegas CMF Assets

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amsterdam Standard Vegas Team

20/05 2016

v1.2

1.2.0.0

Vegas CMF Assets

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amsterdam Standard Vegas Team

20/05 2016

2.0.x-dev

2.0.9999999.9999999-dev

Vegas CMF Assets

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amsterdam Standard Vegas Team

20/05 2016

v2.0

2.0.0.0

Vegas CMF Assets

  Sources   Download

MIT

The Requires

 

The Development Requires

by Amsterdam Standard Vegas Team