Unable to minify Vue.js application
Those compressors simply only support an old version of JavaScript. Their support is restricted to at most ES5. To make your code work, convert it:
(function() {
initApp();
})();
function initApp() {
window.myApp = new Vue({
el: '#wrapper',
data: function() { // changed this line
return {
somedata: []
}
}
});
}
And it should compress.
Details:
They use uglify-js: "^3.3.10"
, that is known for not supporting ES6(uglify-es
does) .
From their repo (emphasis mine):
UglifyJS 3
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit.
Note:
- (...)
uglify-js
only supports JavaScript (ECMAScript 5).- To minify ECMAScript 2015 or above, transpile using tools like Babel.