我正在尝试更改文件
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
我直接对路径进行了硬编码,只是为了测试它是否有效。
我遗漏了什么吗?
问题实际上与构建路径无关。问题是 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;
}
};