question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature req] minifier fails if input folder contains anything else than html files

See original GitHub issue

Hi!

If there are images in the input directory, html-minifier breaks. For example, I use npm script task:

html-minifier --input-dir ./test1 --output-dir ./test2 --html-5 --collapse-whitespace

There is only 1 html file and 1 png image in the folder test1/.

I get the following error:

Minification error on test1/test-icon.png
Parse Error: <����O��... (and goes on)...

I’d like to use html-minifier to minify my static website’s output folder — it contains everything that normal website would contain, including images.

If there is a temporary solution to feed only .html files from the folder into html-minifier, please advise as well, I’m keen to minify all my .html files.

Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
reveltcommented, Jun 16, 2016

Updated the title. I’ll see what I can do 😃

0reactions
reveltcommented, Jul 9, 2016

I am curious though - what is the expectation when skipping over non-HTML files. Do we just store minified files in the output directory, or are we expected to copy over image files etc.?

I have a Hugo-diven static website and I want to run the minifier on the whole /public/ folder — everything that is generated by Hugo. It’s necessary because HTML partials often have spaces everywhere, what adds up when rendered and looks clearly computer-generated with ten spaces, opening <div>, twenty spaces and fifteen line breaks, then some text…

Thanks again for sorting folder recursion + filtering by extension in v3.0.1, I really appreciate that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm scripts: need to minify all HTML files in folder (and ...
npm library minimize works only on per-file but not on folders. I need this to minify my static website's HTML files. Grunt and...
Read more >
Applying minification to all files in a directory · Issue #734
I'm trying to apply html-minifier to all files inside a directory (recursively). I wasn't able to figure out how to do it.
Read more >
How to Minify JavaScript — Recommended Tools and ...
First, you'll copy and paste your JavaScript source code or upload the source code file on the tool. Then, you'll optimize the minification ......
Read more >
How to Minify Your Website's CSS, HTML & Javascript
We minify the files of a website containing CSS, HTML, and Javascript code so your web browser can read them faster. Here is...
Read more >
Bundling and Minification
NET 4.5 that makes it easy to combine or bundle multiple files into ... that includes all the appropriate (that is debug or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found