How do you automate Javascript minification for your Java web applications?

前端 未结 11 1967
广开言路
广开言路 2020-12-07 07:02

I\'m interested in hearing how you prefer to automate Javascript minification for your Java web apps. Here are a few aspects I\'m particularly interested in:

  • H
11条回答
  •  眼角桃花
    2020-12-07 07:32

    I'm writing a framework for managing web assets, called humpty. It aims to be simpler and more modern than jawr or wro4j by using WebJars and ServiceLoaders.

    How does it integrate? Is it part of your build tool, a servlet filter, a standalone program post-processing the WAR file, or something else?

    In development, a servlet processes the assets as necessary. The assets would then be pre-compiled before production and placed in a public folder, so that the only part that is used is generating the correct includes in the HTML.

    Is it easy to enable and disable? It's very unfunny to try and debug a minified script, but it's also useful for a developer to be able to test that the minification doesn't break anything.

    That would be done by switching between development and production modes.

    Does it work transparently, or does it have any side effects (apart from the ones inherent in minification) that I have to consider in my day-to-day work?

    I believe it is transparent, but does strongly favour the use of WebJars.

    Which minifier does it use?

    Whichever one the plugin you put on your classpath uses. Currently looking at writing a plugin for the Google Closure Compiler.

    Does it lack any features that you can think of?

    Still pre-release, though I'm using it in production. The maven plugin still needs a lot of work.

    What do you like about it?

    The simplicity of just adding a dependency to configure the framework

    What don't you like about it?

    It's my baby, I love it all ;)

提交回复
热议问题