webpack的proxy代理路径改写
devServer: { proxy: { context: () => true, target: configJSON.proxy, pathRewrite: function (path, req) { const staticRegExp = /\.(js|css|map|json|html|svg|jpg|jpeg|png)/; if ( configJSON.develop && staticRegExp.test(req.url) && req.url.indexOf('/模块名/') < 0 && req.url.indexOf('/xxx/resources') < 0 ) { return `/xxx/resources${req.url}`; } return path; }, bypass: function (req, res, proxyOptions) { if (req.url.indexOf('/xxx/resources/模块名') >= 0) { return req.url.replace('/xxx/resources', ''); } return null; } } }