Tuesday, August 13, 2013

Versioning main.js in requirejs

<script>
        var require = {
            // https://github.com/jrburke/requirejs/issues/476
              paths: {
                'main': 'main.js?v=MD5_MAIN'
              }
        };
</script>
<script data-main="js/main" src="js/lib/require/require-2.1.5.min.js"></script>

This is one way, and need make sure require config is before require.js script tag.

Another way mentioned in the issue by requirejs author jrburke is using directory. This is a better way than querystring.
<script data-main="v1/js/main" src="v1/js/require.js"></script>

1 comment:

  1. require.config({
    baseUrl: "Scripts/app",
    urlArgs: "v=" + (new Date()).getTime(),
    paths : {
    jquery: "https://code.jquery.com/jquery-2.1.4.min"
    }
    })

    ReplyDelete