简体   繁体   English

使用 create-react-app 的 writeToDisk 不显示工作文件

[英]writeToDisk with create-react-app not displaying work files

I am trying to configure webpack in my react app so that during development, the files are visible in the dist folder (or wherever).我正在尝试在我的 React 应用程序中配置 webpack,以便在开发过程中,文件在dist文件夹(或任何地方)中可见。

So I tried react-app-rewired with the following config所以我尝试使用以下配置进行react-app-rewired

module.exports = function override(config, env) {
    config.devServer = {
        devMiddleware: {
            writeToDisk: true
        }
    }
    return config;
}

But it doesn't seem to work.但这似乎不起作用。 I've been looking for how to make writeToDisk work, and it seems to have changed at some point, because I can't find anything online that works.我一直在寻找如何使writeToDisk工作,它似乎在某个时候发生了变化,因为我在网上找不到任何可用的东西。

How can I get writeToDisk to work so that it writes the hot-reload files to a visible folder when running react-scripts start ?我怎样才能让writeToDisk工作,以便在运行react-scripts start时将热重载文件写入可见文件夹?

I just ended up going with craco instead, which worked.我最终选择了craco ,这很有效。

craco.config.js : craco.config.js

module.exports = {
    devServer: (devServerConfig, { env, paths, proxy, allowedHost }) => {
        devServerConfig.devMiddleware.writeToDisk = true;
        return devServerConfig;
    },
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM