Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ( args.cancel ) {
return;
}
var result = results.join( os.EOL );
var banner = opts.banner ? opts.banner + os.EOL : '';
write( dest, (banner + result) );
me.fire( 'write:file', args );
if ( opts.minimize ) {
var csso = require( 'csso' );
var cssoOptions = opts.cssoOptions || { };
var minimized = csso.justDoIt( result, !!cssoOptions.structureModifications );
var minimizedDest = makeMinName( dest );
write( minimizedDest, (banner + minimized) );
me.fire( 'write:minimized', extend( { }, args, {
dest: minimizedDest
} ) );
}
} ).catch( function ( err ) {
//console.log(err);
var tagName = token[1];
var tagNameLC = tagName.toLowerCase ();
if (tagNameLC == 'script') {
insideScriptTag = false;
} else if (tagNameLC == 'style') {
insideCSSTag = false;
}
processed += "";
break;
case 4:
if (insideScriptTag) {
if (debug) console.info ("Minifying inline javascript: " + insideScriptTag);
processed += minifyJavascript (token[1], null);
} else if (insideCSSTag) {
if (debug) console.info ("Minifying inline CSS: " + insideCSSTag);
processed += csso.justDoIt (token[1]);
} else {
processed += token[1];
}
break;
}
} while (token[0]);
if (SHOW_PRE_MINIFIED_HTML) {
console.info ("-------- PRE-MINIFIED HTML --------");
console.info (processed);
console.info ("-----------------------------------");
}
var minified = html_minifier.minify (processed, {
removeComments: true,
removeCommentsFromCDATA: true,
LmdBuilder.prototype.renderStyles = function (styles, isOptimizeCss) {
if (!styles || !styles.length) {
return '';
}
var allCss = styles
.filter(function (style) {
return style.is_exists;
})
.map(function (style) {
return fs.readFileSync(style.path, 'utf8');
})
.join('\n');
return isOptimizeCss ? csso.justDoIt(allCss, true) : allCss;
};
function css_compressor(str) {
return Csso.justDoIt(str);
}
function css_compressor(str) {
return Csso.justDoIt(str);
}
module.exports = function (file, options, cb) {
var source = file.buffer.toString();
try { source = csso.justDoIt(source) + '\n'; }
catch (er) { return cb(er); }
cb(null, {buffer: new Buffer(source)});
};
function css_compressor(str) {
return Csso.justDoIt(str);
}
LmdBuilder.prototype.renderStyles = function (styles, isOptimizeCss) {
if (!styles || !styles.length) {
return '';
}
var allCss = styles
.filter(function (style) {
return style.is_exists;
})
.map(function (style) {
return fs.readFileSync(style.path, 'utf8');
})
.join('\n');
return isOptimizeCss ? csso.justDoIt(allCss, true) : allCss;
};
return vowFs.read(sourcePath, 'utf8').then(function(data) {
data = csso.justDoIt(data, preserveStructure);
return vowFs.write(targetPath, data, 'utf8');
});
}