[TypeScript] Using Gulp with TypeScript
typescript with Using Gulp
2023-09-14 08:59:20 时间
Package.json:
{ "name": "typescript", "version": "1.0.0", "description": "", "main": "index.js", "dependencies": { "gulp": "^3.9.0", "gulp-typescript": "^2.8.0" }, "devDependencies": { "del": "^1.2.1", "gulp-concat": "^2.6.0", "gulp-plumber": "^1.0.1", "gulp-uglify": "^1.2.0", "run-sequence": "^1.1.2" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" }
Use:
gulpfile.js
/** * Created by Answer1215 on 8/17/2015. */ var gulp = require('gulp'), plumber = require('gulp-plumber'), uglify = require('gulp-uglify'), concat = require('gulp-concat'), ts = require('gulp-typescript'), runSequence = require('run-sequence'), del = require('del'), tsPath = 'typescript/*.ts', jsPath = './js', compilePath = 'js/compiled', dist = 'js/dist'; gulp.task('build', function(callback) { runSequence('clean', ['typescript','compressScripts'], callback); }); gulp.task('compressScripts', function() { gulp.src([ compilePath + 'typescript/*.js' ]) .pipe(plumber()) .pipe(concat('bundle.min.js')) .pipe(uglify()) .pipe(gulp.dest(dist)); }); gulp.task('typescript', function() { var tsResult = gulp.src(tsPath) .pipe(ts({ target: 'ES5', noExternalResolve: true, declarationFiles: false })); tsResult.dts.pipe(gulp.dest(compilePath + '/tsdefinitions')); return tsResult.js.pipe(gulp.dest(compilePath + '/typescript')) }); gulp.task('clean', function(callback) { del([jsPath], {force: true}, callback); }); gulp.task('watch', function() { gulp.watch([tsPath], ['typescript']); }); gulp.task('default', function(callback) { runSequence('build', ['watch'], callback); });
相关文章
- 用 TypeScript 实现斐波那契数列
- 深入浅出 TypeScript
- Typescript: Getting Started
- Create Your Own Redux (Typescript)
- TypeScript基础常用知识点总结
- 「使用 webpack5从0到1搭建React+TypeScript 项目环境」1. React 与 TypeScript 集成
- 【项目总结】TypeScript基础
- 快速掌握 TypeScript 新语法:infer extends
- TypeScript超详细入门教程(上)
- Java和TypeScript开发者之间的区别必须知道
- TypeScript 类型体操:提取对象指定 key 并设置为必填
- Typescript学习笔记,从入门到精通,持续记录
- (一)为什么要使用 TypeScript(二)安装并配置 Ts
- 语句Oracle中简洁的With语句(oracle 中with)
- 分析学习Oracle深入理解使用With 分析(oracle使用with)
- MySQL查询优化使用WITH子句的限制与替代方案(mysql不能用with)