+19
| # CSS Concat | ||
| This module is not intended to do any minification or compression. It's just supposed to concatenate @imported CSS files together and doing it properly. This applies to the relative paths to images as well. | ||
| While npm isn't needed for this module to work, I highly recommend it - it makes managing your modules and it's dependencies very comfortable. | ||
| ## Installation | ||
| npm install -g css-concat | ||
| ## From command-line | ||
| CSS Concat reads from `input.css` and writes to `output.css`. If you don't specify `output.css` explicitly, it will write to `input-out.css`. | ||
| css-concat [input.css] [output.css] | ||
| ## From another node-module | ||
| Calling concat with the path to your CSS file, you will get a string containing the same output as the command-line version, including comments. | ||
| var cssConcat = require('css-concat'), | ||
| outputString = cssConcat.concat('path/to/your.css'); |
+31
| var fs = require('fs'), | ||
| cssConcat = require('../lib/css-concat'); | ||
| fs.readdir('.', function(error, files) { | ||
| if (error) throw error; | ||
| var inFile = '/in/main.css', | ||
| refFile = '/expected/main-out.css'; | ||
| files.forEach(function(file) { | ||
| fs.stat(file, function(error, stats) { | ||
| if (error) throw error; | ||
| if (stats.isDirectory()) { | ||
| var output = cssConcat.concat(file + inFile); | ||
| fs.readFile(file + refFile, function(error, data) { | ||
| if (error) throw error; | ||
| if (data + "" === output) { | ||
| console.log("Passed " + file + "."); | ||
| } else { | ||
| console.log("Failed " + file + "."); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| }); |
+17
-12
@@ -1,8 +0,6 @@ | ||
| exports.concat = function(input, output) { | ||
| exports.concat = function(input) { | ||
| output = output || input.replace('.css','-out.css'); | ||
| var fs = require('fs'), | ||
| path = require('path'), | ||
| outfile = fs.createWriteStream(output), | ||
| output = '', | ||
| urlRegex = /(?:url\([\'\"]*)(.*?)(?:[\'\"]*\))/, | ||
@@ -12,9 +10,12 @@ rootPath = path.dirname(path.resolve(input)), | ||
| lastImport = function(lineArray) { | ||
| var index = 0, | ||
| innerIndex = 0; | ||
| lineArray.forEach(function(line) { | ||
| innerIndex++; | ||
| if (line.indexOf('@import') === 0) index = innerIndex; | ||
| if (line.indexOf('@import') === 0) index = ++innerIndex; | ||
| }); | ||
| return index; | ||
| }, | ||
@@ -35,5 +36,6 @@ concatenate = function(filename) { | ||
| outfile.write('/*' + seperator + '\n'); | ||
| outfile.write(' contents of: ' + path.relative(rootPath, filename) + '\n'); | ||
| outfile.write(' ' + seperator + '*/\n'); | ||
| output += '/*' + seperator + '\n'; | ||
| output += ' contents of: ' + path.relative(rootPath, filename) + '\n'; | ||
| output += ' ' + seperator + '*/\n'; | ||
| } | ||
@@ -52,16 +54,19 @@ | ||
| relImgPath = path.relative(rootPath, currentPath + '/' + imgPath); | ||
| outfile.write(line.replace(imgPath, relImgPath) + '\n'); | ||
| output += line.replace(imgPath, relImgPath) + '\n'; | ||
| } else { | ||
| outfile.write(line + '\n'); | ||
| output += line + '\n'; | ||
| } | ||
| index++; | ||
| }); | ||
| }; | ||
| concatenate(input); | ||
| return output; | ||
| }; |
+2
-2
@@ -5,3 +5,3 @@ { | ||
| "description": "Concatenate @imported CSS files.", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "repository": { | ||
@@ -11,3 +11,3 @@ "type" : "git", | ||
| }, | ||
| "main": "./bin/cssc", | ||
| "main": "./lib/css-concat.js", | ||
| "bin": "./bin/cssc", | ||
@@ -14,0 +14,0 @@ "engines": { |
| /*===================================================== | ||
| contents of: import1.css | ||
| =====================================================*/ | ||
| .rule1 { } | ||
| /*===================================================== | ||
| contents of: main.css | ||
| =====================================================*/ | ||
| .rule2 { } | ||
| /*===================================================== | ||
| contents of: import2.css | ||
| =====================================================*/ | ||
| .rule1 { } | ||
| /*===================================================== | ||
| contents of: import1.css | ||
| =====================================================*/ | ||
| .rule2 { } | ||
| /*===================================================== | ||
| contents of: main.css | ||
| =====================================================*/ | ||
| .rule3 { } | ||
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
6015
16.28%136
1.49%1
-50%20
Infinity%2
100%