Generated HTML:
<script type="text/javascript" src="/assets/jquery-2.2.0.min.js?compile=false" ></script>
<script type="text/javascript" src="/assets/jquery-ui.min.js?compile=false" ></script>
<link rel="stylesheet" href="/assets/jquery-ui.min.css?compile=false" />
<link rel="stylesheet" href="/assets/jquery-ui.theme.min.css?compile=false" />
<link rel="stylesheet" href="/assets/bootstrap.css?compile=false" />
<link rel="stylesheet" href="/assets/grails.css?compile=false" />
<link rel="stylesheet" href="/assets/main.css?compile=false" />
<link rel="stylesheet" href="/assets/mobile.css?compile=false" />
<link rel="stylesheet" href="/assets/application.css?compile=false" />
<script type="text/javascript" src="/assets/igv-1.0.6.js?compile=false" ></script>
<link rel="stylesheet" href="/assets/igv-1.0.6.css?compile=false" />
<script type="text/javascript" src="/assets/jquery-2.2.0.min.js?compile=false" ></script>
<script type="text/javascript" src="/assets/bootstrap.js?compile=false" ></script>
<script type="text/javascript" src="/assets/igv-1.0.6.js?compile=false" ></script>
<script type="text/javascript" src="/assets/jquery-ui.min.js?compile=false" ></script>
<script type="text/javascript" src="/assets/application.js?compile=false" ></script>
As you can see, several assets are being defined twice, for example jquery-2.2.0.min.js, jquery-ui.min.js and igv-1.0.6.js!
My following GSP code looked like this:
GSP:
<asset:javascript src="jquery-2.2.0.min.js"/>
<asset:javascript src="jquery-ui.min.js"/>
<asset:stylesheet src="jquery-ui.min.css" />
<asset:stylesheet src="jquery-ui.theme.min.css" />
<asset:stylesheet src="application.css"/>
<asset:javascript src="igv-1.0.6.js" />
<asset:stylesheet src="igv-1.0.6.css"/>
<asset:javascript src="application.js"/>
Strangely enough, if I remove the following line, then the duplicates are removed:
<asset:javascript src="application.js"/>
Another problem I had was that in production( but worked fine development mode), my javascript files were not being minified even after I set the configuration to use ES6 in my gradle.build file:
assets {
minifyJs = false
minifyCss = true
enableSourceMaps = true
minifyOptions = [
languageMode: 'ES6',
targetLanguage: 'ES6'
]
}
To work around the issue, I set the minifyJs = false as shown above.
At the moment, the asset pipeline just feels buggy and unstable and it's probably better to just disable some of the features in the configuration to get some basic things working.
Not sure if I've misunderstood how assets were meant to be used, but if somebody can explain this, please enlighten me!
No comments:
Post a Comment