Closed VaclavSynacek closed 4 years ago
Hey Vaclav! This plugin uses UglifyJS.minify(), which significantly limits number of options one can pass to the .parse() method: https://github.com/mishoo/UglifyJS2/blob/master/tools/node.js#L70
That's why your parameter gets lost! To sort that out the code invoking UglifyJS2 will have to be re-written, basically I'll need to drop in my own version of .minify() which would support that parameter -- that is neither elegant, nor backward-compatible.
Having said that I feel like it would be quite a convenient feature to have... let me think about it.
For now, to make it less ambiguous, I'll mention the fact that UglifyJS2.minify()
is used in the plugin code in README.
I used this and it works great: https://github.com/haensl/gulp-minify-inline-json
Alright, we're now migrated to Terser and, guess what, it has got exactly the same problem as UgligyJS2! Thinking about it, I can add another minification rail, specifically for JSON, but would it not violate a "do one thing well" principle too much?
@shkuznetsov thank you for the effort. However I have long since stopped needing this. So if this stays open just for myself, it can be closed now.
Uglify has a CLI parameter
--expr
or parser oprionexpression
for parsing JSON. How should I set up options forgulp-minify-inline
so that it invokes Uglify in this JSON mode?I'm trying to minify HTML file that contains JSON data:
I have tried invoking gulp-minify-inline with options like this:
But it fails with JS_Parse_Error probably because the
expr
option is not passed down to Uglify.I have tried several versions of the options such as
expression: true
orparser: {expression: true}
but never got it right. Is this supported? What is the correct way to write options for JSON minification?