How to compile typescript using npm command?

前端 未结 3 937
北海茫月
北海茫月 2021-01-31 10:13

Well I just wanted to know is there any command which will directly compile the typescript code and get the output. Right now, what i am doing is,every time when i make changes

3条回答
  •  孤城傲影
    2021-01-31 10:37

    This is based on solution proposed by @ThomasThiebaud. I had to modify it a little to make sure the files are built in dist/ before nodemon tries to start the server.

    "scripts": {
        "clean": "rimraf dist",
        "build": "tsc",
        "watch:build": "tsc --watch",
        "watch:server": "nodemon './dist/index.js' --watch './dist'",
        "start": "npm-run-all clean build --parallel watch:build watch:server --print-label"
      },
    

    You still need to run npm start to start the whole thing.

提交回复
热议问题