-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support protocol @imports #85
Comments
Regarding this issue, I'm not sure that it's a real good idea. |
Let's see if anyone asks for it. Maybe there's no real "business" value behind it. |
I'm not sure I follow... Wouldn't it be simpler to just keep the |
@XhmikosR, it's also my opinion. |
Sure, let's see if there's any interest in it. |
I officially register interest in such feature. |
@terinjokes can you share your use case if it's any different from the example on top? |
Have a tool that creates static versions of webpages by inlining resources. Right now I'm combing though CSS with Seems a bit wasteful to parse the stylesheet twice. If you don't want to handle setting up the fetches, I'm happy to take a callback. |
@terinjokes Thanks for your use case! Since @abarre suggested we should expose an ability to override request properties (in case of proxies, authentication, etc) it makes me wonder if it's doable via CLI or should we make it the lib option only. A |
Since fetching external data will be asynchronous and clean-css is synchronous, here's an idea how to handle it.
CLI will have a |
Sounds like a good start from this end, I'm already using the library. |
Great! I should have some spare time to push it forward in the coming days. |
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests too (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in binary via --timeout / -t switches.
@terinjokes @abarre if you would like to give it a try then a preliminary but fully functional version is on No changes are necessary when running via CLI. new CleanCSS().minify(source, function(errors, minified) {
...
}); One can also override requests' options via: var options = {
inliner: {
request: { ... }
}
};
new CleanCSS(options).minify(source, function(errors, minified) {
...
}); |
Overall, it looks good, but some feedback before we go any farther. If a callback is provided to minify it automatically resolves external resources as When |
@terinjokes Thanks for the feedback - the thing is callback handling is not finished yet as Thanks for pointing current/next tick thing. Will make sure it's always deferred. |
You can't be API backwards compatible and change when the callback gets called. I think that's as much as part of the API as the method signatures. |
But there is no callback in the current version of clean-css. It will be added in 2.1. |
D'oh! It was already there in the commit added above, so I assumed it was already on master. |
No worries - this branch adds callbacks too! |
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers callback asynchronously.
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
@terinjokes That should be it. Callback will always be deferred via Not sure if we should go for What do you think? |
I don't think that's really an error, maybe if you had sort of debug mode on. I'll give it a run this afternoon and let you know. |
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
@terinjokes Cool, thanks! It indeed makes sense to show that info under debug mode - thanks for the tip. |
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
@terinjokes Did you have a chance to give it a try? Would like to merge it into master soon. |
@GoalSmashers No, been working on other things. going to try it now. |
I get an error on inliner.js:43 where data is an object that doesn't have the function "indexOf". |
Thanks for checking! Could you give it a try with On Dec 21, 2013, at 8:41 PM, Terin Stock notifications@github.com wrote:
|
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
@terinjokes The issue you've reported regarding |
Works now, however are there any chance to dictate how to inline other, non-css, resources? Sorry, I didn't see the other comment. |
Don't worry, I'm just happy it works well now! To inline other resources you can pipe output of clean-css to https://github.com/GoalSmashers/enhance-css - is it an option for you? |
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
* Rewrote inliner to process data asynchronously. * Supports 2xx responses, redirects, errors, and timeouts. * Supports cyclical references. * Supports protocol-less requests (defaults to HTTP). * Supports overriding request options - see http://nodejs.org/api/http.html#http_http_request_options_callback * Supports timeout in ./bin/cleancss via --timeout / -t switches. * Supports inlining local resources only without a callback. * Supports rebasing URLs in remote @imports. * Always triggers a callback asynchronously.
Merged to master to be included in 2.1. Thanks for all the help! |
Hi, I think this is not resolved: cleanCss = require('clean-css');
inst = new cleanCss;
inst.minify('@import url("//fonts.googleapis.com/css?family=Oleo Script Swash Caps");\n.block2 { font-family: \'Oleo Script Swash Caps\'; }\n'); resolves into @import url(//fonts.googleapis.com/css?family=Oleo) Script Swash Caps);.block2{font-family:'Oleo Script Swash Caps'} Which is obviously wrong, look at the "Oleo) Script Swash Caps", why is the closing bracket found after "Oleo"? |
@Slava thanks for bringing that up - have just opened an issue in your name. We will deal with it quickly! |
Example:
The text was updated successfully, but these errors were encountered: