Quantcast

Plugin less-asset-pipeline does not appear to compile less files to css in WAR build

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Plugin less-asset-pipeline does not appear to compile less files to css in WAR build

rstevehole
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:

Gradle Plugins:
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.11.6"

Grails Plugins:
compile "com.bertramlabs.plugins:asset-pipeline-grails:2.11.6"
compile "com.bertramlabs.plugins:less-asset-pipeline:2.11.6"

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:

assets {
minifyJs = true
minifyCss = true
developmentRuntime = false
}

No joy.

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.


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e2d1854d-e3f0-4834-9f0e-1ab0f6d7fe55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plugin less-asset-pipeline does not appear to compile less files to css in WAR build

rstevehole
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.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/985dc6ea-b9df-4d33-8236-6aac6a61b3f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plugin less-asset-pipeline does not appear to compile less files to css in WAR build

Robson Oliveira
Hi, did you get this error? I have the same problem.

Em quinta-feira, 24 de novembro de 2016 16:05:05 UTC-2, Steve Hole escreveu:
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.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/8dc02785-3d78-40bd-8b58-bb1cdf055270%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plugin less-asset-pipeline does not appear to compile less files to css in WAR build

rstevehole
Yes, we did figure it out. I posted the answer in detail in our original question. In summary for those reading this thread however, the behaviour is caused by not including the less-asset-pipeline plugin in the gradle plugin build dependency block. You have to put the plugin in both the gradle AND the application dependency blocks. In the application dependency block, you need to list it as an "asset" dependency rather than "runtime" or "compile".

The documentation on this is quite sparse ... and openly contradictory in some places. A result of several versions of support I'm sure. I've been meaning to go back and update the Grails doc to clarify this and just keep forgetting. Hopefully this is enough for you to move forward.

On Tuesday, 21 March 2017 13:20:44 UTC-6, Robson Oliveira wrote:
Hi, did you get this error? I have the same problem.

Em quinta-feira, 24 de novembro de 2016 16:05:05 UTC-2, Steve Hole escreveu:
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.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/8deae86e-408a-4b41-ab4e-15a1f7c157e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...