Add option processImport set to true by default.
authorabarre <a@fasterize.com>
Fri, 19 Jul 2013 10:01:09 +0000 (12:01 +0200)
committerabarre <a@fasterize.com>
Fri, 19 Jul 2013 10:01:09 +0000 (12:01 +0200)
lib/clean.js
test/unit-test.js

index 11be0df..b15c119 100644 (file)
@@ -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) {
index 6732a58..e67cf8d 100644 (file)
@@ -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);