0

When I use -x with the less compiler to produce a minified CSS file:

lessc -x style.less > style.css

decimals lower than 1 are kept without the zero (.3 is kept as .3) However, if I use --clean-css:

lessc --clean-css style.less > style.css

suddenly .3 changes to 0.3 int the output CSS file.

I have Less v1.7.4. I also have v0.10.30 of node.js which I installed following this guide since I am on Ubuntu 12.04. My clean-css version is 2.1.8, so I think I have already the last version of everything.

** UPDATE **

I installed less following the guide in the less webpage. It made a node_modules directory inside the less directory, with a clean-css directory inside it. I guess this would be the local, but I only have two node modules installed: npm and less, so that would be the only clean-css installation that I have.

This is the tree structure for the clean-css folder:

├── bin
│   └── cleancss
├── History.md
├── index.js
├── lib
│   ├── clean.js
│   ├── colors
│   │   ├── hsl-to-hex.js
│   │   ├── long-to-short-hex.js
│   │   ├── rgb-to-hex.js
│   │   └── shortener.js
│   ├── images
│   │   ├── url-rebase.js
│   │   └── url-rewriter.js
│   ├── imports
│   │   └── inliner.js
│   ├── properties
│   │   ├── optimizer.js
│   │   └── shorthand-notations.js
│   ├── selectors
│   │   ├── empty-removal.js
│   │   ├── optimizer.js
│   │   └── tokenizer.js
│   └── text
│       ├── comments.js
│       ├── escape-store.js
│       ├── expressions.js
│       ├── free.js
│       └── urls.js
├── LICENSE
├── node_modules
│   └── commander
│       ├── index.js
│       ├── package.json
│       └── Readme.md
├── package.json
└── README.md

I tried to run the cssclean binary inside the bin folder, following the suggestion of @seven-phases-max:

. cleancss -o styles.css styles.min.css

And it throws the following errors:

bash: /bin: Is a directory
bash: cleancss: line 5: syntax error near unexpected token `('
bash: cleancss: line 5: `var util = require('util');'

It doesn't throw any of these errors when I run it with the lessc command.

Can you reproduce this, and do you know if there is some file that I can edit to change this behaviour? Cheers

Xirux Nefer
  • 830
  • 1
  • 7
  • 19
  • It depends on Less compiler version and version of `clean-css` included with the compiler. This "Leading zeros" issue is fixed in `clean-css` [v2.1.0](https://github.com/GoalSmashers/clean-css/compare/v2.0.8...v2.1.0) which is included with Less v1.7.0 (and higher). Also note that you can manually update compiler dependencies to the latest `clean-css` version. – seven-phases-max Aug 21 '14 at 17:17
  • @seven-phases-max I just made a `lessc -v` in my terminal and I have Less **v1.7.4**. I also have v0.10.30 of node.js which I installed [following this guide](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager) since I am on Ubuntu 12.04. My `clean-css` version is **2.1.8**, so I think I have already the last version of everything. – Xirux Nefer Aug 21 '14 at 17:58
  • @seven-phases-max P.S. I have also left a comment [in an already closed issue here](https://github.com/GoalSmashers/clean-css/issues/182#issuecomment-52861190), but I don't know if I should have open a new one instead. – Xirux Nefer Aug 21 '14 at 18:07
  • 1
    @Xirux Nefer. It's strange, I actually can't reproduce your results, for me `lessc` 1.7.4 with `--clean-css` outputs digits w/o leading zeros as expected. I can only suspect that maybe you have some versioning conflicts in global vs. local node_modules installation or something, but it's hard to say for sure. – seven-phases-max Aug 21 '14 at 19:39
  • 1
    @Xirux Nefer. Try to process some CSS file directly with `clean-css` tool to find out if it's `lessc`'s fault or something wrong with `clean-css` itself. – seven-phases-max Aug 21 '14 at 19:42
  • @seven-phases-max Thanks for the help. I updated my question. I tried the local processing, but it seems like it doesn't like to be run as a standalone. I'm sure there is sth I can edit in some of those files, but I don't know what or where =( – Xirux Nefer Aug 21 '14 at 20:57
  • I also suspect it can be related to http://stackoverflow.com/a/21171188 (same applies for Ubuntu). – seven-phases-max Aug 21 '14 at 22:04

0 Answers0