简体   繁体   中英

create-react-app how to compile specific .ts file to .js file in the build process?

Currently, $ npm run build compiles files from src/ into /build and everything is working fine. However, there's some specific TypeScript file, src/integer.ts , that I want to compile to its own JavaScript file, build/integer.js and all the other files to be compiled "normally".

This is the project structure:

/src
/build

Here's the package.json file:

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

I don't understand your question. Both the esnext javascript and typescript will be compiled to es5. What special compilation do you need?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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