TypeScript 使用Parcel打包TS代码
初始化 package.json npm init -y
初始化 tsconfig.json tsc --init
安装 parcel cnpm install -D
tsconfig.json 找到配置
"outDir": "./dist", "rootDir": "./src",
package.json 配置
"scripts": { "test": "parcel ./src/index.html" },
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script src="./page.ts"></script> </body> </html>
page.ts
const teacher: string = ‘222‘; console.log(teacher);
执行命令 npm run test,控制台没报错,说明 parcel 会自动对 ts 文件进行编译
相关推荐
彤庆的技术 2020-09-02
xiaofanguan 2020-06-28
锅哥 2020-06-12
changcongying 2020-11-02
changcongying 2020-10-30
苗疆三刀的随手记 2020-10-29
zouph000 2020-10-25
Jruing 2020-10-23
ctg 2020-10-14
PMJ0 2020-10-13
ChaITSimpleLove 2020-10-06
小飞侠V 2020-09-25
QiaoranC 2020-09-25
changcongying 2020-09-17
taizuduojie 2020-09-15
淼寒儿 2020-09-13
lyjava 2020-09-11
锅哥 2020-08-27
ruanhongbiao 2020-08-16