gulp-closure-css-renamer

    0.0.2 • Public • Published

    gulp-closure-css-renamer

    gulp plugin to rename CSS for Google Closure Compiler or any other compiler.

    Installation

    Use npm.

    npm install --save-dev gulp-closure-css-renamer
    

    API

    var gulpClosureCSSRenamer = require('gulp-closure-css-renamer');

    gulpClosureCSSRenamer([options])

    options: Object
    Return: Object (stream.Tansform)

    gulpClosureCSSRenamer constructor accepts a hash as a parameter, i.e., new gulpClosureCSSRenamer(options) with the following options available:

    • sourceMap - boolean. Default value: false.
    • compress - boolean. Default value: true.
    • parseType - string. Default value: 'any'. Available values: 'word', 'full', 'any'.
    • wordSeparator - string. Default value: '-'.
    • renameFile - string. Default value: undefined. Path to rename vocabulary file.
    • formatFunction - function. Default value:
    function(vocabularyAsArray, renameType) {
      var vocabulary = {};
      vocabularyAsArray.forEach(function(el) {
        vocabulary[el.name] = el.abbr;
      });
      return ([
        'goog.provide(\'cssVocabulary\');',
        'goog.setCssNameMapping(',
        JSON.stringify(vocabulary),
        ',' + (renameType == 'full' ? '\'BY_WHOLE\'' : '\'BY_PART\'') + ');'
      ]).join('\n');
    }

    Format function for rename vocabulary file.

    Examples

    var gulp = require('gulp');
    var gulpClosureCSSRenamer = require('gulp-closure-css-renamer');
     
    gulp.task('default', function() {
      gulp.src('./src/buttons.css')
        .pipe(gulpClosureCSSRenamer({
          sourceMap: true,
          compress: true,
          renameFile: './target/rename.js'
        }))
        .pipe(gulp.dest('target'));
    });

    Source Maps can be generated by using gulp-sourcemaps.

    var gulp = require('gulp');
    var gulpClosureCSSRenamer = require('gulp-closure-css-renamer');
    var sourcemaps = require('gulp-sourcemaps');
     
    gulp.task('default', function() {
      gulp.src('./src/buttons.css')
        .pipe(sourcemaps.init())
        .pipe(gulpClosureCSSRenamer({
          sourceMap: true
        }))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('target'));
    });

    Usage with gulp-less.

    var gulp = require('gulp');
    var less = require('gulp-less');
    var gulpClosureCSSRenamer = require('gulp-closure-css-renamer');
     
    gulp.task('less', function() {
      gulp.src('./src/less/main.less')
        .pipe(less())
        .pipe(gulpClosureCSSRenamer({
          compress: true,
          renameFile: './tmp/rename.js'
        }))
        .pipe(gulp.dest('./target/'));
    });

    Install

    npm i gulp-closure-css-renamer

    DownloadsWeekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • efim_dejin