Minification strips out whitespace, comments, and (for JavaScript) renames local variables to shorter names, without changing what the code actually does when it runs. Rather than a hand-rolled regex trick, this uses the same real minifier libraries production build tools rely on — csso for CSS, html-minifier-terser for HTML, and Terser for JavaScript — so the output matches what you'd get from a proper build pipeline.
A correct minifier only removes things that don't affect execution — whitespace, comments, and safely-renameable local names — so well-formed code should behave identically after minifying. Code that relies on unusual quirks (like reading a function's source via toString()) is the rare exception worth testing after minification.
Terser doesn't just remove whitespace — it can shorten local variable and function names, drop dead code branches, and fold constant expressions. CSS and HTML minifiers mostly just strip formatting and redundant syntax, since renaming class names or tag structure would risk breaking the page.
Yes — always keep your readable source as the version you edit, and treat the minified output as a build artifact you regenerate for production. Debugging minified code directly is painful without a source map.