簡體   English   中英

如何更改 react-app-rewired 的構建路徑

[英]How to change build path for react-app-rewired

我正在嘗試在文件config-overrides.json中更改react-app-rewired的構建路徑,如此所述。

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 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
        path.appHtml = 'path_to_index.html';
        return paths;
    }
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM