前端自动化之ts编译

前端自动化之ts编译

gulp引用包:gulp-tsc

gulpfiles.js代码:

var typescript = require('gulp-tsc');

gulp.task('compile', function () {
    return gulp.src(['src/ts/*.ts'])
        .pipe(typescript({
            target: 'es5',//把typescript转换成es5标准的js文件,也可以是es6,但这个node版本不支持
            module: 'commonjs'
        }))
        .pipe(gulp.dest('dist/js/ts/'))
});

然后在serve中监控ts代码的改变并编译

原文地址:https://www.cnblogs.com/s313139232/p/7543505.html