* Fixed issue [#247](https://github.com/GoalSmashers/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch.
* Refixed issue [#250](https://github.com/GoalSmashers/clean-css/issues/250) - based on new quotation marks removal.
* Fixed issue [#257](https://github.com/GoalSmashers/clean-css/issues/257) - turns hsla/rgba to transparent if possible.
+* Fixed issue [#265](https://github.com/GoalSmashers/clean-css/issues/265) - adds support for multiple input files.
* Fixed issue [#275](https://github.com/GoalSmashers/clean-css/issues/275) - handling transform properties.
[2.1.8 / 2014-03-28](https://github.com/GoalSmashers/clean-css/compare/v2.1.7...v2.1.8)
you use `<source-file>` as the very last argument to avoid potential issues):
```
-cleancss [options] <source-file>
+cleancss [options] source-file, [source-file, ...]
-h, --help Output usage information
-v, --version Output the version number
// Specify commander options to parse command line params correctly
commands
.version(buildVersion, '-v, --version')
- .usage('[options] <source-file>')
+ .usage('[options] source-file, [source-file, ...]')
.option('-b, --keep-line-breaks', 'Keep line breaks')
.option('--s0', 'Remove all special comments, i.e. /*! comment */')
.option('--s1', 'Remove all special comments but the first one')
commands.parse(process.argv);
var options = {
- source: null,
+ sources: null,
target: null
};
var cleanOptions = {};
if (commands.timeout)
cleanOptions.inliner = { timeout: parseFloat(commands.timeout) * 1000 };
if (commands.args.length > 0) {
- var source = commands.args[0];
- options.source = source;
- cleanOptions.relativeTo = path.dirname(path.resolve(source));
+ var relativeTo = (cleanOptions.noRebase ? false : cleanOptions.root) || commands.args[0];
+ options.sources = commands.args;
+ cleanOptions.relativeTo = path.dirname(path.resolve(relativeTo));
}
// ... and do the magic!
-if (options.source) {
- fs.readFile(options.source, 'utf8', function(error, data) {
- if (error)
- throw error;
- minify(data);
- });
+if (options.sources) {
+ var data = options.sources
+ .map(function(source) {
+ if (cleanOptions.processImport === false)
+ source += '@shallow';
+
+ return '@import url(' + path.relative(cleanOptions.relativeTo, path.resolve(source)) + ');';
+ })
+ .join('');
+ minify(data);
} else {
var stdin = process.openStdin();
stdin.setEncoding('utf-8');
if (Buffer.isBuffer(data))
data = data.toString();
- if (options.processImport) {
+ if (options.processImport || data.indexOf('@shallow') > 0) {
// inline all imports
var self = this;
var runner = callback ?
var inlinerOptions = merge(defaultOptions, options || {});
var process = function(data, options) {
+ if (options.shallow) {
+ options.shallow = false;
+ options._shared.done.push(data);
+ return processNext(options);
+ }
+
options._shared = options._shared || {
done: [],
left: []
};
var inline = function(data, nextStart, nextEnd, options) {
+ options.shallow = data.indexOf('@shallow') > 0;
+
var importDeclaration = data
.substring(data.indexOf(' ', nextStart) + 1, nextEnd)
+ .replace(/@shallow\)$/, ')')
.trim();
var viaUrl = importDeclaration.indexOf('url(') === 0;
relativeTo: parsedUrl.protocol + '//' + parsedUrl.host,
_shared: options._shared,
whenDone: options.whenDone,
- visited: options.visited
+ visited: options.visited,
+ shallow: options.shallow
});
});
})
_shared: options._shared,
visited: options.visited,
whenDone: options.whenDone,
- localOnly: options.localOnly
+ localOnly: options.localOnly,
+ shallow: options.shallow
});
};
assert.equal(stdout, minimized);
}
}),
+ 'from multiple sources': binaryContext('./test/data/partials/one.css ./test/data/partials/five.css', {
+ 'should minimize all': function(error, stdout) {
+ assert.equal(stdout, '.one{color:red}.five{background:url(data:image/jpeg;base64,/9j/)}');
+ }
+ }),
'to file': binaryContext('-o ./reset1-min.css ./test/data/reset.css', {
'should give no output': function(error, stdout) {
assert.equal(stdout, '');