【问题标题】:How to change outputDir (/build) of TypeScript code in create-react-app如何在 create-react-app 中更改 TypeScript 代码的 outputDir (/build)
【发布时间】:2020-07-15 08:42:31
【问题描述】:

我正在使用 create-react-app 和 TypeScript 模板来管理我的 React 项目 (yarn create react-app my-app --template typescript)

当我运行react-scripts build 时,我的代码内置在/build 文件夹中。如何自定义这个目录?

我试图在tsconfig.json 中更改compilerOptions 中的outDir,但这似乎被CRA 忽略了。

【问题讨论】:

    标签: reactjs typescript create-react-app


    【解决方案1】:

    目前看来不可能,

    基于 QA:Use custom build output folder when using create-react-app


    不过,有一些解决方法。

    例如,您可以构建然后移动它

    在 package.json 中

    "build": "react-scripts build && mv build docs"
    

    参考:问题:https://github.com/facebook/create-react-app/issues/1354

    那里还有很多其他的解决方案,找到一个合适的就好了。

    【讨论】:

      【解决方案2】:

      您可以设置 BUILD_PATH 并在 Windows 上这样做 set \"BUILD_PATH=new-folder\" && react-scripts build

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-16
        • 2019-02-20
        • 1970-01-01
        • 2022-06-19
        • 1970-01-01
        • 2018-01-09
        • 2019-02-01
        相关资源
        最近更新 更多