Reputation: 499
In my current grails project we're minifying our JavaScript files with UglifyJS and are also using these minified resources in the development environment. As you can image this is a little pain in the ass to debug on a minified version, fix the bug in the not-minified one, minify it and debug again. Therefore I'd like to include the not-minified versions within the development environment and the minified ones in production. So I tried adjusting the ApplicationResources.groovy to have the following scheme:
environments {
development {
modules = {
core {
resource url:"js/core.js"
}
}
}
production {
modules = {
core {
resource url:"js/core.min.js"
}
}
}
}
This somehow doesn't work and exceptions are thrown such as
Caused by GrailsTagException: Error executing tag <r:layoutResources>: No module found with name [core]
What am I doing wrong here?
Update:
I'm not sure I understand this correctly. I tried the following which doesn't work either:
Update:
Adding ids does the trick :)
ApplicationResources.groovy
modules = {
core {
resource id: 'core', url:"js/core.min.js"
}
}
DevelopmentResources.groovy
environment {
development {
modules = {
overrides {
core {
resource id: 'core', url:"js/core.js"
}
}
}
}
}
Upvotes: 3
Views: 1515
Reputation: 2512
Try defining dev and prod resources modules in separate files. like StaticResources.groovy and ProductionResources.groovy.
Each Resources file ultimately provides Grails with one "modules" closure, Grails then combines the definitions from the closures provided by each file to produce the final configuration.
Here's the complete nabble discussion.
Upvotes: 6