Skip to content

minCSS Option Throws Error in 2.17.2 and Up #50

Closed
@smschrader

Description

@smschrader

Error -

events.js:74
        throw TypeError('Uncaught, unspecified "error" event.');
...
  at ...\node_modules\gulp-bundle-assets\n
ode_modules\gulp-minify-css\node_modules\clean-css\lib\clean.js:71:41
  at process._tickCallback (node.js:419:13)

is thrown when option is enabled for Less files. Issues goes away with earlier releases.
Seems to be an issue with the clean-css module.

Might be related to Issue https://github.com/jonathanepollack/gulp-minify-css/issues/61

Sample Config:

var lazypipe = require(__base + 'lazypipe'),
    gif = require(__base + 'gulp-if'),
    less = require(__base + 'gulp-less');

function stringEndsWith(str, suffix) {
  return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

function isLessFile(file) {
  return stringEndsWith(file.relative, 'less');
}

var styleTransforms = lazypipe()  
  .pipe(function() {
    return gif(isLessFile, less({
        rootpath: "../"     
    }));
  });

module.exports = {
    bundle: {        
        main: {      
            styles: [
                __webapp + 'stylesheet/src/main.less'
            ],
            options: {
                useMin: false, // pre-minified files                 
                minCSS: true, 
                rev: true,
                transforms: {
                    styles: styleTransforms
                }
            }
        }
    }
};

Sample Gulp Task:

//Bundle, compress, and write less to dist
gulp.task('lessMain', ['cleanCSS'], function() {  
    return gulp.src(projectPaths.cssMainConfig)        
        .pipe(bundle().on("error", gutil.log))        
        .pipe(bundle.results({
            fileName: 'main.result',
            dest: projectPaths.cssResults,
            pathPrefix: '<%=request.getContextPath()%>/dist/styles/'
        }))        
        .pipe(gulp.dest(projectPaths.cssDist));
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions