From ef49ea0d7d0820639ec8ed5c64cb29d4392140ed Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Thu, 8 Jan 2015 22:48:33 +0000 Subject: [PATCH] Fixes #431 - documents behaviour when no callback given. --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index caec4e77..20950b0a 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzip ```js var CleanCSS = require('clean-css'); var source = 'a{font-weight:bold;}'; -var minimized = new CleanCSS().minify(source).styles; +var minified = new CleanCSS().minify(source).styles; ``` CleanCSS constructor accepts a hash as a parameter, i.e., @@ -127,6 +127,21 @@ CleanCSS constructor accepts a hash as a parameter, i.e., If input styles are a product of CSS preprocessor (LESS, SASS) an input source map can be passed as a string. * `target` - path to a folder or an output file to which __rebase__ all URLs +#### How to make sure remote `@import`s are processed correctly? + +In order to inline remote `@import` statements you need to provide a callback to minify method, e.g.: + +```js +var CleanCSS = require('clean-css'); +var source = '@import url(http://path/to/remote/styles);'; +new CleanCSS().minify(source, function (errors, minified) { + // minified.styles +}); +``` + +This is due to a fact, that, while local files can be read synchronously, remote resources can only be processed asynchronously. +If you don't provide a callback, then remote `@import`s will be left intact. + ### How to use clean-css with build tools? * [Broccoli](https://github.com/broccolijs/broccoli#broccoli) : [broccoli-clean-css](https://github.com/shinnn/broccoli-clean-css) -- 2.34.1