Sublime Forum

Minify Failing to Work With HTML Files

#1

I’m using sublime text 3 on ubuntu 22.04.5, and I’ve installed Minify via Package Control according the instructions at https://packagecontrol.io/packages/Minify (including checking clean-css etc. were installed correctly).

I’m trying to use Minify on a simple script called test_script.html (basically just “hello world”), but it won’t create a test_script.min.html file or even throw up an error message. I can’t minify through a right-click in the file editor, nor with Tools.

I should mention that HTML Minifier https://packagecontrol.io/packages/HTML%20Minifier works fine, but for the actual use cases I want to deal with it’s not going to be enough.

For reference, here is my Minify.sublime-settings script

{
// Auto-minify files on save?
“auto_minify_on_save”: true,

// you can specify command line parameters for .html minification
“html-minifier_options”: “–collapse-boolean-attributes --collapse-whitespace --html5 --minify-css --minify-js --process-conditional-comments --remove-comments --remove-empty-attributes --remove-redundant-attributes --remove-script-type-attributes --remove-style-link-type-attributes”,

// Open resulting file (minified or beautified)?
“open_file”: false,

// Only Minify specified file types (css, js, json, html, svg) when “auto_minify_on_save” is used
“allowed_file_types”: [
“css”,
“js”,
// “json”,
“html”,
// “svg”
],

// you can specify command line parameters for cleancss
“cleancss_options”: “-O2”,

“debug_mode”: true,
}

0 Likes

#2

Do you see any errors in the console (View > Show Console)?

0 Likes

#3

Whoops, would’ve been good to check the console first! Thanks bschaaf.

I indeed get a

FileNotFoundError: [Errno 2] No such file or directory: ‘html-minifier’

even though html-minifier is working fine in the terminal.

After a lot more thought I strongly suspect the FileNotFoundError is arising from using nvm, cf. the discussion here:

https://stackoverflow.com/questions/23149527/setting-up-paths-in-sublime-with-nvm .

I’ll try out some of the suggestions on this stackoverflow thread in the near future and update this topic if I get a fix.

0 Likes