| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/gulp-csso/ |
Upload File : |
'use strict';
var csso = require('csso'),
gutil = require('gulp-util'),
Transform = require('stream').Transform,
applySourceMap = require('vinyl-sourcemaps-apply');
function processParseError(source, filename, details, message) {
function formatLines(start, end) {
return lines.slice(start, end).map(function(line, idx) {
var num = String(start + idx + 1);
while (num.length < maxNumLength) {
num = ' ' + num;
}
return num + ' |' + line;
}).join('\n');
}
var lines = source.split(/\n|\r\n?|\f/);
var column = details.column;
var line = details.line;
var startLine = Math.max(1, line - 2);
var endLine = Math.min(line + 2, lines.length + 1);
var maxNumLength = Math.max(4, String(endLine).length) + 1;
return [
'CSS parse error ' + filename + ': ' + message,
formatLines(startLine - 1, line),
new Array(column + maxNumLength + 2).join('-') + '^',
formatLines(line, endLine)
].join('\n');
}
module.exports = function (options) {
var stream = new Transform({ objectMode: true });
stream._transform = function (file, encoding, cb) {
function handleError(error) {
if ('parseError' in error) {
error = processParseError(source, inputFile, error.parseError, error.message);
}
cb(new gutil.PluginError('gulp-csso', error));
}
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
return handleError('Streaming not supported');
}
var inputFile = file.relative;
var source = String(file.contents);
var cssoOptions = {
filename: inputFile,
sourceMap: Boolean(file.sourceMap),
restructure: true,
debug: false
};
if (options === undefined || typeof options === 'boolean') {
// for backward capability
cssoOptions.restructure = !options;
} else if (options) {
// extend default csso options
for (var name in options) {
if (options.hasOwnProperty(name) && name !== 'filename') {
cssoOptions[name] = options[name];
}
}
}
try {
var result = csso.minify(source, cssoOptions);
if (result.map) {
applySourceMap(file, result.map.toJSON());
} else {
file.sourceMap = null;
}
file.contents = new Buffer(result.css);
cb(null, file);
} catch(error) {
handleError(error);
}
};
return stream;
};