node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

symfony2-assets-grunt-helper

Grunt Helper for Symfony2 Assets

This is a small helper to ease the usage of Grunt with Symfony2. It may be, that you can configure the paths in grunt in a way, which makes this plugin obsolete - but I haven't found a way yet. Especially multiple wildcards in a path * seem to be an issue, like here: src/*/*/Resources/assets/..

This helper returns the prepared grunt configuration for the sass and the uglify tasks:

Usage

var gruntSymfony2Assets = require("symfony2-assets-grunt-helper");
var gruntConfig = gruntSymfony2Assets();

Passing your own config

You can pass your own config (used in the options field in the definition for the tasks) for these two tasks:

var gruntSymfony2Assets = require("symfony2-assets-grunt-helper");
 
var myOwnConfig = {
    sass: {
        // special config goes here 
    },
    uglify: {
        // special config goes here 
    }
};
 
 
var gruntConfig = gruntSymfony2Assets(myOwnConfig);

Example: you want to enable sourcemaps in SASS.

var gruntSymfony2Assets = require("symfony2-assets-grunt-helper");
 
var myOwnConfig = {
    sass: {
        sourcemap: true
    }
};
 
var gruntConfig = gruntSymfony2Assets(myOwnConfig);

Please not that all config values, which you don't pass explicitly, will be filled with the default values.

Default config

This module defines some default options for both sass and uglify:

// SASS 
{
    style:       "compressed",
    sourcemap:   false,
    lineNumbers: false,
    precision:   5,
    quiet:       true // bourbon throws a lot of deprecations with SASS 3.3 
}
 
// Uglify 
{
    compress: true,
    beautify: false,
    report:   "gzip"
}

Adding your own config

var gruntSymfony2Assets = require("symfony2-assets-grunt-helper");
var gruntConfig = gruntSymfony2Assets();
 
// here goes your own config 
gruntConfig.uglify.my_stuff = { /* ... */ };
gruntConfig.copy = { /* ... */ };
// ... 
 
 
grunt.initConfig(gruntConfig);