I have a Grails (2.3.6) app, and have included the asset-pipeline
plugin as a dependency. In my Config.groovy
:
plugins {
// Lots of other stuff
compile ":asset-pipeline:1.8.7"
}
In myapp/web-app/js/application.js
(generated for me by Grails), I have only the following single line of code:
alert("Hello!");
Then in my grails-app/views/index.gsp
:
<html>
<head>
<asset:javascript src="application.js" />
</head>
<body>
...
</body>
</html>
When I do a grails run-app
, I don't see my JS alert(...)
statement fire. Have I positioned my application.js
file incorrectly? Have I configured the asset-pipeline
plugin incorrectly? Anything else I'm doing wrong? I just want to see my alert box!
Additionally, following the " put CSS at the top, and JS at the bottom " convention, I was wondering if anyone could chime in as to how I could reposition the application.js
to appear at the bottom of the <body/>
tag. My understanding was that asset-pipeline
assets only work inside of <head/>
.
Your static files go in grails-app/assets/. See organization for the details.
According to the documentation for the asset-pipeline plugin your assets should be under the grails-app/assets/ directory structure. Each type of asset is under a sub folder as follows:
grails-app/assets/javascripts
grails-app/assets/images
grails-app/assets/stylesheets
Move your application.js
into the javascripts directory for asset-pipeline to pick it up.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.