Plugin less-asset-pipeline does not appear to compile less files to css in WAR build
We have run into a problem when deploying an application as a WAR file to an AWS Elastic Beanstalk Tomcat container. Any Less resources defined in the project are NOT compiled into CSS and placed in the WAR file. Neither are they rendered as CSS on demand from the WAR file (no surprise there). Any reference to the generated CSS file comes back as HTTP 404 (no surprise there either). We have verified that it happens in any naked Tomcat container as well.
The application is building in Grails 3.2.2 and using the following plugin combination:
The versions listed above are latest-and-greatest, but we have tried several different versions back to 2.8.2. You can recreate this behaviour in any new application by doing the following:
1. Create a new empty app with grails create-app.
2. Add the plugins defined above.
3. Replace the application.css file created by Grails with an application.less file. You can put whatever you like inside as long as it is valid Less (which includes literal CSS).
4. Do a run-app and validate that your less file is processed running in development mode and the default Grails UI is properly rendered.
5. Generate a WAR file from the project and deploy to any valid Tomcat instance and validate that your "application.css" file that should have been compiled from application.less is not there.
At this point is starts to look like a bug, but I'm surprised that others haven't run into this. Also, we are not entirely sure how it is supposed to work after reviewing the code. We presumed that that when the "grails prod war" command was issued that it should compile static CSS files that would show up in the build/assets directory alongside the other assets, but we only get the original an name mangled versions of the Less files. We have tried turning off the development runtime support in build.gradle so that resources are compiled and held statically:
minifyJs = true
minifyCss = true
developmentRuntime = false
At this point we presume there is something wrong with the gradle plugin that makes it not compile to static CSS files, but that just may be a misunderstanding of how it is supposed to work. Perhaps it still compiles the Less files on at runtime on demand but permanently retains and returns the compiled version from that point when running from a WAR with developmentRuntime = false. We believe that we should be seeing the compiled CSS files in build/assets because of the following statement in the Grails Asset Pipeline doc:
Precompiling for Production
Assets are now automatically precompiled into target/assets when you create a war file. This should further simplify the deployment process. During WAR creation, only the changed assets are compiled making your precompiler phase a bit quicker. If, for any reason, you want to ensure a clean assets folder, feel free to run grails asset-clean.
During WAR build your assets are also minified using Closure Compiler.
Any insight on this is much appreciated. It is a show stopper for us at the moment and we need to get this resolved or dump our support for Less.
Re: Plugin less-asset-pipeline does not appear to compile less files to css in WAR build
An additional note on this. Everything works as expected when doing a run-app from Grails, a boot-run in Gradle/Eclipse. It only happens when running a naked WAR file manually deployed to a Tomcat instance.