如何在webpack-dev-server中设置文件的默认后缀?

如何在webpack-dev-server中设置文件的默认后缀?

问题描述:

我用的WebPack-DEV-服务器到服务器我project.Here是个问题,当浏览器发送请求像http://localhost:9000/test/menuList,实际上可以,我希望它找到http://localhost:9000/test/menuList.json。我应该怎么做?如何在webpack-dev-server中设置文件的默认后缀?

您可以尝试调整的WebPack-DEV-服务器代理对象pathRewrite财产

devServer: { 
    contentBase: <Your-Value>, 
    proxy = { 
     '/test/menuList': { 
      target: http://localhost:9000/test/menuList, 
      pathRewrite(req, options) { 
        return req + '.json'; 
      } 
     } 
    } 
    ... 
}