【问题标题】:create-react-app how to compile specific .ts file to .js file in the build process?create-react-app 如何在构建过程中将特定的 .ts 文件编译为 .js 文件?
【发布时间】:2020-09-11 13:14:55
【问题描述】:

目前,$ npm run build 将文件从src/ 编译成/build,一切正常。但是,我想将一些特定的 TypeScript 文件 src/integer.ts 编译成它自己的 JavaScript 文件 build/integer.js 和所有其他要“正常”编译的文件。

这是项目结构:

/src
/build

这是package.json 文件:

"dependencies": {
    "react-scripts": "3.4.1",
}
...
"scripts": {
     "build": "react-scripts build",
}

【问题讨论】:

    标签: reactjs typescript webpack create-react-app react-scripts


    【解决方案1】:

    我不明白你的问题。 esnext javascript 和 typescript 都将被编译为 es5。需要什么特别的编译?

    【讨论】:

    • 不是一个很好的答案。人们想要这样做的原因有很多。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-09
    • 1970-01-01
    • 2021-07-13
    相关资源
    最近更新 更多