Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a CSS minifier than can resolve import statements?

Tags:

import

css

minify

Is there a CSS minifier tool that can resolve @import statements?

I'd like to be able to load multiple CSS files on my local machine but have them all resolved into one file when the website gets pushed out into production.

like image 504
Helephant Avatar asked Mar 07 '11 16:03

Helephant


People also ask

What does a CSS Minifier do?

Minifying a CSS file implies the removal of unnecessary characters in the source code to reduce the file size and facilitate faster loading of the site. When a user requests a webpage, the minified version is sent instead of the full version, resulting in faster response times and lower bandwidth costs.

How do you Unminify a CSS code?

Using our free tool is super simple. Just copy paste your minified code into the box above, or drag-and-drop entire files in the outlined area. Confirm whether you want to unminify JavaScript or CSS code, then click the “Unminify” button. Within seconds, you'll have access to the unminified version of your code.

Can you Uglify CSS?

It can be used to combine and minify JavaScript assets so that they require less HTTP requests and make your site load faster. UglifyCSS is a CSS compressor/beautifier that is very similar to UglifyJS. In this article, the installation, configuration and usage of UglifyJS is shown in detail.


3 Answers

I recently started using LESS, beyond imports allows you to use:

  • Variables
  • Mixins
  • Parametric Mixins
  • Nested rules
  • Operations
  • Color functions
  • Namespaces
  • Scope
  • Comments
  • Escaping

So far I'm glad with my experience using LESS.

It's easy to use and the page is documented with good examples.

like image 51
Diogo Cardoso Avatar answered Nov 15 '22 18:11

Diogo Cardoso


You can use SASS, with the SCSS syntax. SASS is much more than a minifier: it is actually a CSS preprocessor which adds some goodies like variables or macros to the CSS syntax. But you can choose to simply ignore these features (although I advise you to have a look): any valid CSS file is actually valid SCSS.

SASS can then compile your SCSS in valid CSS, and it can manage multiple files and output a single minified .css file.

You can try it just as a minification tool for now, and start using the advanced features when you feel like experimenting.

like image 28
Andrea Avatar answered Nov 15 '22 19:11

Andrea


css-compressor (based on yuicompressor) inlines @import statements - in fact that is its primary purpose:

https://github.com/samilyak/css-compressor

like image 23
pete otaqui Avatar answered Nov 15 '22 19:11

pete otaqui