0

我正在创建一个 npm 包,您可以在其中创建指向src文件夹的指针作为源和指向反应应用程序的指针。目前,我只是将src文件夹复制到 react 应用程序,但是我在原始src文件夹中所做的任何更改都不会导致应用程序的热重新加载。

这是我的代码 run.js

const run = () => {
    // Lets read our config file
    const rawData = fs.readFileSync(configFile);
    const config: Config = JSON.parse(rawData.toString());
    const { src } = config.envs[config.current]
    const { root } = config.envs[config.current];
    console.log(chalk.cyan(`Running source:${src} at root:${root}`));

    // Lets use npm watch to check if anything changes in our 'src' directory
    // this is the biggest issue with the package

    // Copy src folder to our root folder and place it into a folder called '/src'
    // Preferably, I would rather have the react app point to this src folder
    shell.cp("-R", src, root + "/src");
    shell.cd(root);
    shell.exec("npm run start");
}

我希望在src指针目录更改时让我的反应应用程序热重新加载,而不是将我的复制src到反应应用程序中。

为了更好地理解这个功能,你可以在这里参考我的 npm 包

4

0 回答 0