2017 © Pedro Peláez
 

library assetic-extra

A collection of extra assetic resources to use with Symfony AsseticBundle.

image

gremo/assetic-extra

A collection of extra assetic resources to use with Symfony AsseticBundle.

  • Sunday, March 25, 2018
  • by gremo
  • Repository
  • 1 Watchers
  • 4 Stars
  • 11,806 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 42 % Grown

The README.md

assetic-extra

Latest stable Downloads total GitHub issues, (*1)

A collection of extra assetic resources to use with Symfony AsseticBundle., (*2)

Table of Contents

Installation

Install this library using Composer:, (*3)

composer require gremo/assetic-extra

Filters

Note: with Symfony 3.3 you can replace %kernel.root_dir%/.. with %kernel.project_dir% for filters configuration., (*4)

The following extra filters can be configured and used in your templates., (*5)

Babel

JavaScript transpiler for node.js (https://babeljs.io)., (*6)

Configuration, (*7)

assetic:
    # ...
    babeljs:
        resource: '%kernel.root_dir%/../vendor/gremo/assetic-extra/Resources/filter/babeljs.xml'
        # options here

Options (reference), (*8)

  • bin: path to your babel binary (default: /usr/bin/babel)
  • retain_lines
  • presets: a string or array of presets to use (preset name if installed globally, path otherwise)
  • plugins: a string or array of plugins to use (plugin name if installed globally, path otherwise)
  • compact
  • minified
  • no_babel_rc
  • auxiliary_comment_before
  • auxiliary_comment_after
  • parser_opts
  • generator_opts

Note: Babel will look for .babelrc file in current asset directory and will travel up the directory tree (see Lookup behavior), unless you specify the no_babel_rc option. This means you can put your .babelrc file in your project root without cluttering your config.yml., (*9)

Usage, (*10)

{% javascripts '../app/Resources/js/*.js' filter='babeljs' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

Browserify

Lets you require('modules') in the browser (http://browserify.org)., (*11)

Credits goes to the original author (https://github.com/kriswallsmith/assetic/pull/669), I changed it a bit and added trasforms support., (*12)

Configuration, (*13)

assetic:
    # ...
    browserify:
        resource: '%kernel.root_dir%/../vendor/gremo/assetic-extra/Resources/filter/browserify.xml'
        # options here

Options, (*14)

  • bin: path to your browserify binary (default: /usr/bin/browserify)
  • node: path to your node binary (default: %assetic.node.bin%, set to null to use browserify binary instead)
  • node_paths: paths to add to Node.js environment when using node option (default: %assetic.node.paths%)
  • transforms a string or array of Browserify transform to apply

Usage, (*15)

Note: there is no need to combine assets (modules/module1.js in the example) as long as you require your module. Browserify filter will take care of combining them in the output file., (*16)

{% javascripts '../app/Resources/js/main.js' filter='browserify' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

Note: the assetic:watch command will regenerate the assets only if you change the "main" script. Modules changes will not be monitored as they are not included in the javascripts tag., (*17)

Example of main.js:, (*18)

// main.js
require('./modules/module1.js');
console.log('main.js');

Example of modules/module1.js:, (*19)

// modules/module1.js
console.log('modules/module1.js');

CSSO

CSSO (CSS Optimizer) is a CSS minifier (https://github.com/css/csso)., (*20)

Configuration, (*21)

assetic:
    # ...
    csso:
        resource: '%kernel.root_dir%/../vendor/gremo/assetic-extra/Resources/filter/csso.xml'
        # options here

Options (reference), (*22)

  • bin: path to your csso binary (default: /usr/bin/csso)
  • comments
  • force_media_merge
  • restructure_off
  • usage

Usage, (*23)

{% stylesheets '../app/Resources/css/*' filter='csso' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

Tip: fast and safe options, (*24)

csso:
    # ...
    comments: none
    restructure_off: true

PostCSS

A tool for transforming CSS with JavaScript (http://postcss.org)., (*25)

Configuration, (*26)

assetic:
    # ...
    postcss:
        resource: '%kernel.root_dir%/../vendor/gremo/assetic-extra/Resources/filter/postcss.xml'
        # options here

Options (reference), (*27)

  • bin: path to your postcss binary (default: /usr/bin/postcss)
  • no_map: disable the default inline sourcemaps
  • use: list of postcss plugins to use
  • parser: custom postcss parser
  • stringifier: custom postcss stringifier
  • syntax: custom postcss syntax
  • config: set a custom path to look for a config file

Usage, (*28)

{% stylesheets '../app/Resources/css/*' filter='postcss' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

Node-sass

Parses SASS/SCSS into CSS using the LibSass bindings for node.js (https://github.com/sass/node-sass)., (*29)

Configuration, (*30)

assetic:
    # ...
    nodesass:
        resource: '%kernel.root_dir%/../vendor/gremo/assetic-extra/Resources/filter/nodesass.xml'
        # options here

Options (reference), (*31)

  • bin: path to your node-sass binary (default: /usr/bin/node-sass)
  • import_paths
  • indent_type
  • indent_width
  • linefeed
  • output_style
  • precision
  • source_comments
  • source_map_location
  • source_map_public_dir

Usage, (*32)

{% stylesheets '../app/Resources/scss/style.scss' filter='nodesass' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

Tip: Boostrap 4, (*33)

Use this options for Bootstrap 4 (see package.json):, (*34)

nodesass:
    # ...
    precision: 6

Tip: source maps, (*35)

In order to generate the source maps, you'll need to specify a public accessible directory where the .map files can be placed (source_map_location) together with the base path (source_map_public_dir) which will be used when generating the urls to the mapping files:, (*36)

nodesass:
    # ...
    source_map_location: '%kernel.root_dir%/../web/assets/maps'
    source_map_public_dir: '/assets/maps'

Recipes

ES6 modules with Browserify

Write ES6 JavaScript modules using import/export style and make it work in the browser., (*37)

Problem: Browserify filter transform your source file and not your transpiled one, so it would fail at the first import or export keyword. Solution: only use the browserify filter with babelify transform filter configuration:, (*38)

Note if Browserify cannot find the babelify module, try installing it locally in your project folder and use the absolute path., (*39)

browserify:
    resource: '%kernel.root_dir%/../vendor/gremo/assetic-extra/Resources/filter/browserify.xml'
    transforms:
        - '[ babelify --presets env ]'

The Versions

25/03 2018

dev-master

9999999-dev

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss postcss assetic browserify babel babeljs csso

25/03 2018

v1.1.0

1.1.0.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss postcss assetic browserify babel babeljs csso

22/03 2018

v1.0.5

1.0.5.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss assetic browserify babel babeljs

11/03 2018

v1.0.4

1.0.4.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss assetic browserify babel babeljs

28/02 2018

v1.0.3

1.0.3.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss assetic browserify babel babeljs

23/09 2017

v1.0.2

1.0.2.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss assetic browserify babel babeljs

17/09 2017

v1.0.1

1.0.1.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss assetic

17/09 2017

v1.0.0

1.0.0.0

A collection of extra assetic resources to use with Symfony AsseticBundle.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

sass scss assetic