modern-web-template icon indicating copy to clipboard operation
modern-web-template copied to clipboard

Compiled coffeescripts loading order in debug mode

Open wuciawe opened this issue 9 years ago • 2 comments

It seems that in the debug mode the loading order of the compiled coffeescripts are not specified and may cause error. In my case, the app.js is loaded after other javascript files which causes undefined module errors.

wuciawe avatar Jul 17 '15 09:07 wuciawe

@wuciawe Change the last few lines of index.scala.html as below. It will ensure app.js is loaded prior to other javascript files.

<!-- Coffee script compiled resources (generated) -->
<script src='@routes.Assets.versioned("javascripts/app.js")' type="text/javascript"></script>

@for(script <- javascripts) {
    @if(!script.endsWith("app.js")){
        <script src='@routes.Assets.versioned(script)' type="text/javascript"></script>
    }
}

lalanikarim avatar Aug 24 '15 15:08 lalanikarim

@jimmy00784 This should work in debug mode, but I remember that in the product mode all of those scripts will be compiled into one script file (through uglify, digest, and gzip). Although we can modify the index.scala further to make correct includings which is what I do now, it looks not so neat. Does there exist better solution? Is require.js suitable in this situation? If so, would you give me a simple demo? (I am new to uglify, digest, gzip, requirejs, thank you so much for your reply.)

wuciawe avatar Aug 25 '15 03:08 wuciawe