我的publicPath是/static/dist。当我的开发服务器运行时,我如何将static/dist代理到/?
我知道我可以:
let publicPath;
if (process.env.NODE_BUILD_DEPLOYMENT_PATH) {
// Change process.env.NODE_BUILD_DEPLOYMENT_PATH to match the path to your files
// in production (could be S3, CloudFront, etc.)
publicPath = process.env.NODE_BUILD_DEPLOYMENT_PATH;
} else {
publicPath = 'http://localhost:8099/';
}但我需要代理人。它用于预渲染。渲染后,我需要为我所有的静态文件添加static/dist前缀。但是当我的开发服务器运行时,我想要/的代理static/dist。
例如:static/dist/js -> /js。
发布于 2021-11-12 20:35:05
解决方案是:
server: {
port: options.devServer.port,
proxy: {
'/static/dist/*': {
target: 'http://localhost:8099',
pathRewrite: {'^/static/dist/': ''}
}
}
},https://stackoverflow.com/questions/69948490
复制相似问题