This forum has moved, please join us on github discussions. We will keep these old posts available for reference. Thank you!

JS minification for production

Hi everyone!

I’m trying to minify my project making minify: true inside app.js. However, I got an error saying:

Error: uglify threw an exception while compiling:

most likely there is invalid javascript in that file:

Unexpected token: name (iconURL)

I found something related to Uglify not been able to parse ES6. I was able to create the minified asset by changing one line in my code, but then apparently I have a problem related with the order the assets are being loaded in the bundled file. The console keep logging that one of the methods I’m using are not a function.

Does anybody have a good example of how to configure a compiler like webpack to work with Apostrophe or how I can manage the dependency order of all the assets?

Thanks

Hi fila, stackoverflow is the right place for how-to questions about apostrophe, tagged apostrophe-cms. This forum is for announcements and general discussion.

You should be using webpack to precompile ES6 anyway for IE11 support. See:

https://apostrophecms.org/docs/tutorials/getting-started/pushing-assets.html#pushing-a-c-s-s-stylesheet-without-l-e-s-s-compilation

For tips on implementing that, although the actual use of webpack is outside the scope of Apostrophe. Basically you just want to push its final output .js file as an apostrophe asset.