-
Notifications
You must be signed in to change notification settings - Fork 572
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
Support for ES6 minification #1040
Comments
Bump. |
/cc @kangax |
Workaround: const jsMinify = require('terser').minify;
const htmlMinify = require('html-minifier').minify;
const htmlMinifyOptions = {
...
minifyJS: (text, inline) => {
const res = jsMinify(text, { warnings: true })
if (res.warnings) console.log(res.warnings)
if (res.error) {
console.log(text)
throw res.error
}
return res.code
}
...
}
...
output = htmlMinify(output, htmlMinifyOptions) |
Wish there was a workaround for the CLI too… |
@alexlamsl do you think can we solve this? |
@jantimon i think we can use workaround from #1040 (comment) in |
I deleted |
@LaurentGoderre probably fear of breaking things..... I also need this feature. <script>
let mail = 'example' + '@' + 'gmail.com';
document.getElementById("hidden_email").text = mail;
document.getElementById("hidden_email").href = 'mailto:' + mail;
</script> |
It seems the current maintainer is not interested to help with this. I'll create a fork and a patch to replace this as we have even more issues with uglify-js >=3. |
@kangax hey! Maybe @DanielRuf should send a PR....? I saw his code and seems good, he also accepted another important PR.... @kangax or add someone as a collaborator so that we can keep the project updated and moving forward? Thanks |
@rodrigograca31 well, after reporting an issue with uglify-js and getting this feedback I don't think that there is any interest from the current maintainer to switch to terser: #1048 (comment) Anyways, here is a version which uses terser: https://danielruf.github.io/html-minifier-terser |
Yeah, the bigger problem is that there was another big project that depended on this one.... so if we improved the original project it would trickle down and improve other projects.... |
Which project exactly do you mean? In general a new major version should prevent any breaking changes in the other project(s) unless they do not use SemVer ranges for their dependencies or pin them. |
Cant remember specifically but the first 2 here are pretty big: https://www.npmjs.com/browse/depended/html-minifier |
Well, these are packages of the webpack org that are mostly maintained by @jantimon and I am also in the webpack team. Bumping the major version to 5 will not produce any problems. So this should provide a chance to migrate to a new version with a new minify engine for JS and ES. |
Imho there is no real reason to not do this step. |
|
@DanielRuf thanks for |
|
Hi
the
html-webpack-plugin
is making heavy use ofhtml-minifier
to keep the html compact.Now that many browsers support ES6 out of the box, people start using ES6 inside script tags.
According to @evilebottnawi from the
webpack
team using ES6 is not possible becausehtml-minifier
is not capable of parsing ES6: jantimon/html-webpack-plugin#1262When
webpack
was faced with the same problem they made a switch toterser
which has now about 6 million downloads per week.(taken from their official readme)
There was already a proposal to do the same change for the
html-minifier
: #1034It would mean to replace
html-minifier/package.json
Line 63 in 51ce10f
terser
The text was updated successfully, but these errors were encountered: