Giter VIP home page Giter VIP logo

css-minify's Introduction

CSS MINIFY

logo

Build Status Visual Studio Marketplace Visual Studio Marketplace license:mit Coveralls github branch Snyk Vulnerabilities for GitHub Repo

This is a very simple vscode extension. Takes your css file and minify it. It doesn't need any special configuration and it doesn't mess up your css file. This tests are based on Mocha framework.

How to

Just press Ctrl|Cmd + F1|F2 and type css minify

Features

  • Removes the units from 0 values. From 0px to 0
  • Removes the 0 from any float value. From 0.16em to .16em
  • Removes the last ; from a closure.
  • Removes useless white spaces.
  • Reduce hexadecimals values. From #ffffff to #fff
  • Removes single and double quotes.
  • Replace none by 0. (only in font-size-adjust, border and outline)

The extension will generate a new file with the the same name plus min.css and save it in the same folder of your css file you are minifying.

Be aware of how you format your code

If you don't format your code well the extension won't work as espected.

  • Don't do this
-webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.12), 0 1px 5px 0 rgba(0, 0, 0, 0.2);
  • Do this
-webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
                    0 3px 1px -2px rgba(0, 0, 0, 0.12),
                    0 1px 5px 0 rgba(0, 0, 0, 0.2);
  • Don't do this
@font-face {
    font-family: 'pxgrotesk-regular';
    src: url('pxgrotesk-regular.eot');
    src: url('pxgrotesk-regular.eot?#iefix') format('embedded-opentype'), url('pxgrotesk-regular.woff2') format('woff2'), url('pxgrotesk-regular.woff') format('woff'), url('pxgrotesk-regular.ttf') format('truetype'), url('pxgrotesk-regular.svg#svgFontName') format('svg');
}
  • Do this
@font-face {
    font-family: 'pxgrotesk-regular';
    src: url('pxgrotesk-regular.eot');
    src: url('pxgrotesk-regular.eot?#iefix') format('embedded-opentype'),
         url('pxgrotesk-regular.woff2') format('woff2'),
         url('pxgrotesk-regular.woff') format('woff'),
         url('pxgrotesk-regular.ttf') format('truetype'),
         url('pxgrotesk-regular.svg#svgFontName') format('svg');
}
  • Don't do this
.className, p > div, #id {
}
  • Do this
.className,
p > div,
#id {
}

Enjoy it :)

css-minify's People

Contributors

dracotmolver avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

css-minify's Issues

Wrong space removal in content property

Css-minify currently appears to remove all whitespace from quoted strings, however this is not necessarily desirable in the css content property.

On my page I am using the content property to add an arrow before collapsible elements, however upon minification the resulting element goes from:
image

To:
image

I have confirmed in the minified css file that this is in fact caused by css-minify.

Converting "none" and "unset" to "0"

CSS-minify has very recently started converting properties such as display: none to display: 0 and clip-path: unset to clip-path: 0. This renders the styles void, hence they are ignored by the browser.

Space removed in CSS width: calc() rules

One space is removed here and shouldn't be :

This rule:

.grid-item { width: calc((100% / 3) - 20px); }

gives:

.grid-item{width:calc((100% / 3)- 20px)}

Result: the rule doesn't work anymore because space before minus is removed.

improve your vscode docs

please improve your vs code docs as in list it makes someone confuse


image

it just simple error but can let beginner not understand your extension

Add spaces in some URLs

Example :

In style.css :

@import url("//fonts.googleapis.com/css?family=Maven+Pro:400,500,700,900");

In style.min.css :

@import url("//fonts.googleapis.com/css?family=Maven + Pro:400,500,700,900");

Issue :

There are some spaces before and after the "+" symbol in the minified url.
It produces bugs like 404 errors.

Space removed before "[" and after "]"

Hi @DracotMolver , it's me again ;)

I experienced another bug:

.my-form[disabled=true] .my-input { cursor: not-allowed; }

is minified as:

.my-form[disabled=true].my-input{cursor:not-allowed;}

removing space between attribute value selector ([disabled=true]) and children class (.my-input)

As well as
.accordion [data-toggle='collapse']
is minified as
.accordion[data-toggle='collapse']

whitespaces in calc()

CSS-minify removes spaces from calc() expression. I.e. calc(100% + 5px) ends up as calc(100%+5px) which doesn't work.

Missing space before asterisk selector

It is removing the space infront of an asterisk when used as a global selector.

#aptApp * { 
   box-sizing: content-box;
}

becomes

#aptApp*{box-sizing:content-box;}

which failes as a selector it was intended for.

expected
#aptApp *{box-sizing:content-box;}

Space after :not

I have found that the minify process is eliminating spaces following a :not property. For instance: body:not(.logged-in) .greeting becomes body:not(.logged-in).greeting, thereby breaking the assigned values.

Ctrl|Cmd + F1 doesn't work.

Tried [ Ctrl|Cmd + F1 ] on VS Code 1.14.2 and didn't work. But when clicked only F1 it let me to write css minify.

Removing quotes from font formats

The minifying is removing quotes from the font format, so

@font-face{
   font-family:'pxgrotesk-regular';
   src:url('pxgrotesk-regular.eot');
   src:url('pxgrotesk-regular.eot?#iefix') format('embedded-opentype'), 
   url('pxgrotesk-regular.woff2') format('woff2'), 
   url('pxgrotesk-regular.woff') format('woff'), 
   url('pxgrotesk-regular.ttf') format('truetype'), 
   url('pxgrotesk-regular.svg#svgFontName') format('svg');
}

becomes

@font-face{
   font-family:'pxgrotesk-regular';
   src:url(pxgrotesk-regular.eot);
   src:url(pxgrotesk-regular.eot?#iefix) format(embedded-opentype), 
   url(pxgrotesk-regular.woff2') format(woff2), 
   url(pxgrotesk-regular.woff') format(woff), 
   url(pxgrotesk-regular.ttf') format(truetype), 
   url(pxgrotesk-regular.svg#svgFontName) format(svg);
}

Then the browser[chrome] isn't rendering correctly, if I add quotes back to jus the format() it fixes it.

Thanks for your extension.

zero in file names

If css file contains any path to file with name ending with 0, i.e. "bg-section10.jpg", CSS-minify resolve it to "bg-section1.jpg" which breaks dependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.