Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-combo

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-combo - npm Package Compare versions

Comparing version 0.2.9 to 0.3.0

examples/multiple-build.js

111

lib/index.js

@@ -38,2 +38,4 @@ /**

cfg.suffix = cfg.suffix || '.combo';
cfg.sourceDir = path.dirname(cfg.target);

@@ -110,3 +112,3 @@

fileContent = commentTpl.join('') + config.linefeed + fileContent;
var cssFileExt = '.combo.css';
var cssFileExt = config.suffix + '.css';
if(config.compress){

@@ -122,3 +124,4 @@ utils.log('start compress file.', 'debug');

if(path.extname(config.output) !== '.css'){
comboFile = path.join(config.output, path.basename(config.target).replace(/(.source)?.css/, cssFileExt));
comboFile = path.resolve(config.output, path.basename(config.target).replace(/(\.source)?\.css/, cssFileExt));
utils.log('dest is dir, I guess the output file is: ' + comboFile, 'debug');
}

@@ -145,2 +148,3 @@

var self = this;
// utils.log('Analyzing ' + self.config.target, 'debug');
if(content){

@@ -154,11 +158,7 @@ var reg = /@import\s*(url)?\(?['"]([^'"]+)\.css['"]\)?[^;]*;/ig,

self.getFileContent(filePath, function(data){
// if(content){
data = self.modifySubImportsPath(data,filePath);
data = data.replace(/(['"]|\():/g,'$1');
data = data.replace(/(['"])%/g,'$1');
content = content.replace(result[0], '\n' + data + '\n');
content = self.analyzeImports(content, callback);
// }else{
// utils.log('no content', 'debug');
// }
data = self.modifySubImportsPath(data,filePath);
data = data.replace(/(['"]|\():/g,'$1');
data = data.replace(/(['"])%/g,'$1');
content = content.replace(result[0], '\n' + data + '\n');
content = self.analyzeImports(content, callback);
});

@@ -224,34 +224,66 @@ }else{

config.base = path.dirname(file);
fs.readFile(file, '', function(err, data){
if(err){
utils.log(err, 'error');
throw self.error(err);
}
config.inputEncoding = config.inputEncoding ? config.inputEncoding : utils.detectCharset(data);
var fileContent = iconv.decode(data, config.inputEncoding);
// var fileContent = data;
utils.log('file charset is: ' + config.inputEncoding, 'debug');
var data = fs.readFileSync(file);
utils.log('Cur file is ' + self.config.target, 'debug');
utils.log('file read: ' + file, 'debug');
// preserve data url and comment.
var preservedTokens = [];
fileContent = compressor._extractDataUrls(fileContent, preservedTokens);
fileContent = compressor._extractComments(fileContent, preservedTokens);
config.inputEncoding = config.inputEncoding ? config.inputEncoding : utils.detectCharset(data);
var fileContent = iconv.decode(data, config.inputEncoding);
utils.log('file charset is: ' + config.inputEncoding, 'debug');
// start analyze file content
self.analyzeImports(fileContent, function(data){
utils.log('analyze done.', 'debug');
// after combo, @charset position may be changed. since the output file encoding is specified, we should remove @charset.
data = data.replace(/@charset\s+['|"](\S*)["|'];/g, '');
// restore all comments back.
data = compressor._restoreComments(data, preservedTokens);
self.generateOutput(data);
report.imports = self.imports;
report.target = self.config.target;
report.output = self.config.output;
report.content = data;
callback && callback(null, report);
});
// preserve data url and comment.
var preservedTokens = [];
fileContent = compressor._extractDataUrls(fileContent, preservedTokens);
fileContent = compressor._extractComments(fileContent, preservedTokens);
// start analyze file content
self.analyzeImports(fileContent, function(data){
utils.log('analyze done.', 'debug');
// after combo, @charset position may be changed. since the output file encoding is specified, we should remove @charset.
data = data.replace(/@charset\s+['|"](\S*)["|'];/g, '');
// restore all comments back.
data = compressor._restoreComments(data, preservedTokens);
self.generateOutput(data);
report.imports = self.imports;
report.target = self.config.target;
report.output = self.config.output;
report.content = data;
callback && callback(null, report);
});
// fs.readFile(file, '', function(err, data){
// if(err){
// utils.log(err, 'error');
// throw self.error(err);
// }
// utils.log('Cur file is ' + self.config.target, 'debug');
// utils.log('file read: ' + file, 'debug');
//
// config.inputEncoding = config.inputEncoding ? config.inputEncoding : utils.detectCharset(data);
// var fileContent = iconv.decode(data, config.inputEncoding);
// utils.log('file charset is: ' + config.inputEncoding, 'debug');
//
// // preserve data url and comment.
// var preservedTokens = [];
// fileContent = compressor._extractDataUrls(fileContent, preservedTokens);
// fileContent = compressor._extractComments(fileContent, preservedTokens);
//
// // start analyze file content
// self.analyzeImports(fileContent, function(data){
// utils.log('analyze done.', 'debug');
// // after combo, @charset position may be changed. since the output file encoding is specified, we should remove @charset.
// data = data.replace(/@charset\s+['|"](\S*)["|'];/g, '');
// // restore all comments back.
// data = compressor._restoreComments(data, preservedTokens);
// self.generateOutput(data);
//
// report.imports = self.imports;
// report.target = self.config.target;
// report.output = self.config.output;
// report.content = data;
// callback && callback(null, report);
// });
//// self.analyzeImports();
// });
}

@@ -283,2 +315,3 @@ };

var funcs = [];
_.forEach(files, function(file, index){

@@ -285,0 +318,0 @@ funcs.push(function(cb){

{
"name":"css-combo",
"version":"0.2.9",
"version":"0.3.0",
"description":"css module combo tool",

@@ -5,0 +5,0 @@ "author":"daxingplay <daxingplay@gmail.com>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc