javascriptrequirejsr.js

require.js compiled versioning


I had moduar SPA with require.js. My version control was ...

require.config({
    urlArgs: "bust="+((document.querySelector('#mainRest') && document.querySelector('#mainRest').getAttribute('data-version')) || 'noVer')});

where including require js ...

<script id='mainRest' data-main="js/rest/main" src="js/rest/require.js" data-version="30062015"></script>

In the way above I had a parameter for downloading dependencies.

Now i have lot of dependencies (templates, views) and i have to compile my require.js structure into single js (using r.js). Of course now I don't have any dependencies except the main one compiled file.

The question is: How can I add version parameter to the compiled file?

<script data-main="js/rest/compiled" src="js/rest/require.js?ver1" ></script>

Solution

  • I wonder but it is possible to set version directly through the "data-main" directive...

    <script data-main="js/rest/compiled.js?ver=101" src="js/rest/require.js?ver1" ></script>