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

时间:2017-10-19 08:14:57

标签: webpack-dev-server

我使用webpack-dev-server为我的项目提供服务。这是一个问题,当浏览器发送 http://localhost:9000/test/menuList 之类的请求时,我希望它能找到 { {3}} 即可。我该怎么办?

1 个答案:

答案 0 :(得分:0)

您可以尝试调整Webpack-dev-server代理对象 pathRewrite 属性

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