在另一个应用程序中运行React开发服务器

问题描述 投票:0回答:1

在我们旧的.jsp应用程序中,我们正在整合react。

我的react开发服务器运行在 http:/localhost:3000 和现有的应用 http:/localhost:8100.

我把所有需要的js & reacting的CSS文件都包含在JSP页面中,工作正常。

当我在React中使用懒加载的时候,比如说:"你可以从本地服务器上加载,而不是从Dev服务器上加载。

import('some-file.js').then(file => {
   // Some work
});

在这种情况下,Webpack试图从localhost:8100而不是Dev服务器加载chunk。

我正在使用 反应脚本 的开发和构建。

enter image description here

reactjs webpack react-router webpack-dev-server
1个回答
1
投票

尝试添加 publicPath 像下面的webconfig.js文件。

output: {
        //
        publicPath: 'http://localhost:3000/static/js/dist' or
        // publicPath : 'http://localhost:3000/dist'
    }
© www.soinside.com 2019 - 2024. All rights reserved.