Skip to content
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

Css minifier not working anymore #51

Closed
Taxman972 opened this issue Jan 31, 2017 · 18 comments
Closed

Css minifier not working anymore #51

Taxman972 opened this issue Jan 31, 2017 · 18 comments

Comments

@Taxman972
Copy link

Hi,

Since the last update I can't minify any css file anymore I followed the step to install and update :
npm install -g clean-css-cli uglifycss js-beautify html-minifier uglify-js minjson svgo
npm update -g clean-css-cli uglifycss js-beautify html-minifier uglify-js minjson svgo

I even add clean-css but impossible to minify a CSS file.

Here a picture
http://imgur.com/a/70RDq
sublime text 2, windows7

@tssajo
Copy link
Owner

tssajo commented Jan 31, 2017

@Taxman972 Sorry to hear that! I just tested it on my local PC (Windows 7 x64, SublimeText 3) and CSS file minification worked just like before. From the error message you sent, it seems to me that there is a problem with your nodejs installation... Can you open up a CMD window and try to run the cleancss command from there? I believe that you'll get an error there, too. If that is the case, you might consider updating nodejs to the latest stable version on your computer (download it from here: https://nodejs.org/en/). After you installed a newer version of nodejs, you should go to the command prompt and issue this command again:

npm install -g clean-css-cli uglifycss js-beautify html-minifier uglify-js minjson svgo

followed by this command:

npm update -g clean-css-cli uglifycss js-beautify html-minifier uglify-js minjson svgo

Please let me know if the above helped or not. Thanks!

@tssajo
Copy link
Owner

tssajo commented Jan 31, 2017

@Taxman972 Also, maybe your source CSS file is referencing another CSS file which is not present on your local disk. Search for "@import" in your source CSS file.
Please try to minify a known good CSS file first, possibly a small one which does not have any @import statements. Just to make sure that cleancss is working on your computer.

@simontrice
Copy link

simontrice commented Jan 31, 2017

Hi @tssajo

I am having the same issue as @Taxman972. I have a clean install of Sublime, nodejs including all CLI and the minify package. This is the error I am getting.

Error modal

when running in command line I get this error

Error CLI

I have no @import references in any of my css files

Running sublime text 3 and Windows 10

@tssajo
Copy link
Owner

tssajo commented Jan 31, 2017

@simontrice Thanks for the screenshots! Seems to me that it is a bug in the new clean-css-cli program. It is very likely affecting you only because you are on Windows and your CSS file is located on a different drive than the C: drive.
Would you please copy your "Two Bad Mice" folder to C: and try it again there? Just to verify that I am correct with my assumption. Please report me back. Thanks!

@simontrice
Copy link

Hi again @tssajo

I have been doing some digging and it looks like clean-css is using the full path, including the path from the application working directory in the file output and file selection. I tested by navigating into the directory holding the css file and running clean-css from there. The file was converted successfully.

I think that the package needs to make the directory containing the file to be created the working directory before calling clean-css.

If I am wrong then please excuse my ignorance, I don't use python.

@tssajo
Copy link
Owner

tssajo commented Jan 31, 2017

@simontrice You are correct, but it seems to me that it is a bug in clean-css-cli program. I will report this bug and request a fix from the author of clean-css-cli.

In the meantime, can you try to copy your project folder to the C: drive and see if it works from there? I believe that it should. Can you confirm this?

As a temporary solution, please downgrade your cleancss program on you PC:

npm uninstall -g clean-css-cli
npm install -g clean-css@3.4.24

@simontrice
Copy link

hi @tssajo

I was writing the last comment as you were posting so missed it. I have copied the full dev directory to the C drive and get the same issue

C: Drive Test

Have been trying to change version of clean-css but I have been unable to make any progress as it is giving me errors when trying to uninstall. I am going to try removing node/npm completely and trying again from scratch. I will let you know if there are any problems with the earlier version.

@ahkui
Copy link

ahkui commented Jan 31, 2017

change CSS minify engine to uglifycss and Wait clean CSS update

@simontrice
Copy link

will do and thanks for the swift response

@tssajo
Copy link
Owner

tssajo commented Jan 31, 2017

@simontrice The error is different on drive C: ! So I was right. :) You have another issue: spaces in your directory name. Please rename the directory to "TwoBadMice" (no spaces) and try it on drive C:
I'm pretty sure that it will work then!

@simontrice
Copy link

simontrice commented Jan 31, 2017

@tssajo

You are correct about that, it worked perfectly. How do I change the minify engine to uglifycss

edit: nvm, found it in the default settings

@tssajo
Copy link
Owner

tssajo commented Jan 31, 2017

@simontrice In ST go to Preferences / Package Settings / Minify / Settings -- Default then highlight everything (e.g. with Ctrl+A) and copy it into the clipboard (Ctrl+C). Close the Settings -- Default file.
Now go to Preferences / Package Settings / Minify / Settings-- User and paste the whole thing there from the clipboard (Ctrl+C). Now, find this line in Settings -- User:

// "cssminifier": "clean-css",

and change it to:

"cssminifier": "uglifycss",

However, I personally like clean-css better than uglifycss... Maybe you can temporary work on your C: drive until they fix clean-css-cli. I already reported the bug: clean-css/clean-css-cli#3

@Taxman972
Copy link
Author

I changed to uglifycss too really bad clean-css bug.

@tssajo
Copy link
Owner

tssajo commented Feb 7, 2017

@Taxman972 , @simontrice

The issue has been fixed in version 4.0.5 of clean-css-cli , see:
clean-css/clean-css-cli#3

So you can change back the following line in your settings file from:

    "cssminifier": "uglifycss",

to:

    // "cssminifier": "clean-css",

Also, do not forget to update your clean-css-cli program:
npm uninstall -g clean-css
npm install -g clean-css-cli
npm update -g clean-css-cli

@tssajo
Copy link
Owner

tssajo commented Feb 7, 2017

In addition to the above, in version 4.0.0+ of clean-css (and clean-css-cli) the following options are no longer valid: --s0 -s

    "cleancss_options": "--s0 -s --skip-rebase",

so I override the above in my Minify Settings -- User file with the following:

    "cleancss_options": "--skip-rebase -O1 specialComments:off",

@megaroeny
Copy link

@tssajo I just installed a fresh version of your package, and I my CSS file was also not getting minified. I had to do this:

Also, do not forget to update your clean-css-cli program:
npm uninstall -g clean-css
npm install -g clean-css-cli
npm update -g clean-css-cli

After that, it worked. I had to use sudo as well

@tssajo
Copy link
Owner

tssajo commented Feb 20, 2017

@jaminroe Thanks for the report. But this is a known issue. clean-css became clean-css-cli not too long ago. I updated the installation instructions for Minify at that time. But I assumed that a user who is installing Minify does NOT have an old version of clean-css installed globally on his system. In case he has then your instructions are correct: the old clean-css package must be uninstalled first and then the new clean-css-cli package must be install globally (using the -g option). Hopefully your comment will help some people who run into the same situation as you did. Thanks!

@megaroeny
Copy link

Ah yes, that is what my case was. I had installed your package a while back, but reinstalled it today to make sure I had the latest version. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants