javascript - Grails asset-pipeline not picking up resource requirements -


i have grails (2.3.6) app , have configured use asset-pipeline:

// buildconfig.groovy plugins {     compile ":asset-pipeline:1.8.7" } 

in grails-app/assets/javascripts directory, have:

  • myapp.js
  • fizz.js
  • buzz.js

then in grails-app/views/index.gsp:

<!doctype html> <html>     <head>         <title>my app</title>         <link rel="stylesheet" type="text/css" href="${resource(dir: 'css', file: 'myapp.css')}" />     </head>     <body>         <div id="home" class="page">             <!-- content... -->         </div>         <asset:javascript src="myapp.js" />     </body> </html> 

and finally, in myapp.js:

= require fizz.js = require buzz.js = require_self  // initialize application. init();  function init() {     alert("do stuff!"); } 

when grails run-app, app starts fine. when go view page source (for index.gsp) get:

<!doctype html> <html>     <head>         <title>my app</title>         <link rel="stylesheet" type="text/css" href="/static/css/myapp.css" />     </head>     <body>         <div id="home" class="page">             <!-- content... -->         </div>         <script src="/assets/myapp.js?compile=false" type="text/javascript" ></script>     </body> </html> 

but when click on /assets/myapp.js?compile=false link, view source, exact same js above:

= require fizz.js = require buzz.js = require_self  // initialize application. init();  function init() {     alert("do stuff!"); } 

so not asset-pipeline not translating these require statements @ top of myapp.js , pulling in specified js files, not stripping requires out either. how can configure plugin correctly pull in other js libs (fizz.js , buzz.js)?

there appropriate syntax needs used require directives when using asset-pipeline.

this how myapp.js should start (without empty first line):

//= require fizz.js //= require buzz.js //= require_self 

refer usage documentations in detail.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -