如何更改react-app-rewired的构建路径

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

我正在尝试更改文件

react-app-rewired
config-overrides.json
的构建路径,如此处所述。

module.exports = {
    paths: function (paths, env) {
        paths.appBuild = 'C:\\Projects\\jhipster\\src\\main\\webapp\\app';
        return paths;
    }
};

但是没有考虑到这一点,我收到以下错误:

Could not find a required file.
Name: index.html
Searched in: C:\Projects\jhipster\public

我直接对路径进行了硬编码,只是为了测试它是否有效。

我遗漏了什么吗?

javascript path create-react-app react-app-rewired
1个回答
1
投票

问题实际上与构建路径无关。问题是 React 期望有一个

public/index.html
文件,但找不到任何此类文件。我猜您要么重命名了
public
文件夹,要么将
index.html
移到了其他地方。

解决方案:告诉

react-app-rewired
在哪里可以找到
index.html

// config-overrides.json
module.exports = {
    paths: function (paths, env) {
        paths.appBuild = 'C:\\Projects\\jhipster\\src\\main\\webapp\\app';
        // Tell the app where our public folder is
        paths.appPublic = 'path_to_public_folder';
        // Tell the app where our index.html is
        paths.appHtml = 'path_to_index.html';
        return paths;
    }
};
© www.soinside.com 2019 - 2024. All rights reserved.