Why is requirejs trying to load .map?

巧了我就是萌 提交于 2019-12-08 19:04:19

问题


I am trying to load scripts from a CDN (cdnjs to be specific), and in requirejs you have to leave the extension off like so:

require.config({
    baseUrl: '/static/js/',
    paths: {
        underscore: ['//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min']
    },
    shim: {
        'underscore': {
            exports: '_'
        }
    }
});

But when I do this, the browser tries to load underscore-min.map and not underscore-min.js.

How do I fix this, and also what is a .map?


回答1:


.map files are needed for sourceMap support in the browser. This is the last line from the file you load from the CDN:

 //# sourceMappingURL=underscore-min.map

This line makes your browser to load the .map file.



来源:https://stackoverflow.com/questions/17898165/why-is-requirejs-trying-to-load-map

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!