Sup*_*per 28 typescript package.json
我不想使用grunt或gulp来编译ts文件.我只想在我的package.json中这样做:
"scripts": {
"build": "tsc main.ts dist/"
},
Run Code Online (Sandbox Code Playgroud)
可能吗?
bas*_*rat 43
"build":"tsc main.ts dist /"
强烈建议您使用tsconfig.json然后使用-p编译器选项来构建代码.请看:编译 - 上下文
以下是使用tscNPM脚本的设置
在里面
npm init
npm install typescript --save
Run Code Online (Sandbox Code Playgroud)
然后在你的package.json中添加一些脚本:
"scripts": {
"build": "tsc -p ./src",
"start": "npm run build -- -w"
},
Run Code Online (Sandbox Code Playgroud)
npm run build npm start请享用
如果要编译运行,可以使用ts-node 模块。
npm install --save-dev ts-node
npm install --save-dev typescript
Run Code Online (Sandbox Code Playgroud)
并运行:
"scripts": {
"start": "ts-node index.ts"
},
Run Code Online (Sandbox Code Playgroud)
index.ts 导入的所有其他打字稿文件(以及从 index.ts 依赖项导入)将被编译和执行。
| 归档时间: |
|
| 查看次数: |
29572 次 |
| 最近记录: |