Is it possible to stop requireJS from adding the .js file extension automatically?

前端 未结 3 1127
梦谈多话
梦谈多话 2020-12-02 11:53

I\'m using requireJS to load scripts. It has this detail in the docs:

The path that is used for a module name should not include the .js extension,

3条回答
  •  悲哀的现实
    2020-12-02 12:39

    If you don't feel like adding a dependency on noext, you can also just append a dummy query string to the path to prevent the .js extension from being appended, as in:

    require.config({
        paths: {
            'signalr-hubs': '/signalr/hubs?noext'
        }
    });
    

    This is what the noext plugin does.

提交回复
热议问题