From: abarre Date: Fri, 19 Jul 2013 10:01:09 +0000 (+0200) Subject: Add option processImport set to true by default. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=61897a8f71e307026214756eeb49e7b61c8986d5;p=clean-css.git Add option processImport set to true by default. --- diff --git a/lib/clean.js b/lib/clean.js index 11be0df7..b15c119c 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -58,6 +58,11 @@ var CleanCSS = { options.keepBreaks = options.keepBreaks || false; + //active by default + if (options.processImport === undefined) { + options.processImport = true; + } + // replace function if (options.debug) { var originalReplace = replace; @@ -85,17 +90,20 @@ var CleanCSS = { // replace all escaped line breaks replace(/\\(\r\n|\n)/mg, ''); - // inline all imports - replace(function inlineImports() { - data = CleanCSS._inlineImports(data, { - root: options.root || process.cwd(), - relativeTo: options.relativeTo + if (options.processImport) { + // inline all imports + replace(function inlineImports() { + data = CleanCSS._inlineImports(data, { + root: options.root || process.cwd(), + relativeTo: options.relativeTo + }); }); - }); - // strip comments with inlined imports - if (data.indexOf('/*') > -1) - removeComments(); + // strip comments with inlined imports + if (data.indexOf('/*') > -1) { + removeComments(); + } + } // strip parentheses in urls if possible (no spaces inside) replace(/url\((['"])([^\)]+)['"]\)/g, function(match, quote, url) { diff --git a/test/unit-test.js b/test/unit-test.js index 6732a58c..e67cf8d2 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -886,5 +886,11 @@ title']", "@import url(/partials-absolute/base.css);", ".base2{border-width:0}.sub{padding:0}.base{margin:0}" ] - }, { root: path.join(process.cwd(), 'test', 'data') }) + }, { root: path.join(process.cwd(), 'test', 'data') }), + '@import with option processImport': cssContext({ + 'of an unknown file': [ + "@import url(/fake.css);", + "@import url(/fake.css);" + ] + }, {processImport : false}) }).export(module);