diff --git a/gulpfile.js b/gulpfile.js index 8a82e05..7b12d15 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,52 +1,18 @@ const gulp = require('gulp'); +const shell = require('gulp-shell'); +const sequence = require('gulp-sequence'); gulp.task('clean', () => { const del = require('del'); return del('./dist/'); }); -gulp.task('compile-ts', () => { - const ts = require('gulp-typescript'); - const tsProject = ts.createProject('./tsconfig.json'); - const dest = tsProject.options.outDir; - return tsProject.src() - .pipe(tsProject()) - .pipe(gulp.dest(dest)); -}); +gulp.task('compile-ts', shell.task('tsc -m commonjs')); -gulp.task('compile-ts-umd', () => { - const ts = require('gulp-typescript'); - const tsProject = ts.createProject('./tsconfig.json'); - const path = require('path'); - const dest = path.join(tsProject.options.outDir, 'umd'); - tsProject.options.module = 3; - return tsProject.src() - .pipe(tsProject()) - .pipe(gulp.dest(dest)); -}); +gulp.task('compile-ts-umd', shell.task('tsc -t es5 -m umd --outDir ./dist/umd/')); -gulp.task('watch-ts', async () => { - const ts = require('gulp-typescript'); - const tsProject = ts.createProject('./tsconfig.json'); - const path = require('path'); - const dest = tsProject.options.outDir; - await tsProject.src() - .pipe(tsProject()) - .pipe(gulp.dest(dest)); - return gulp.watch(['./src/**/*.ts'], (file) => { - const tsProject = ts.createProject('./tsconfig.json'); - const relative = path.relative('./', path.dirname(file.path)); - const outDir = tsProject.options.outDir; - const dest = path.join(outDir, relative); - return gulp.src(file.path) - .pipe(tsProject()) - .pipe(gulp.dest(dest)); - }); -}); +gulp.task('watch-ts', shell.task('tsc -w -t es5 -m umd --outDir ./dist/umd/')); -gulp.task('default', (cb) => { - const sequence = require('gulp-sequence'); - sequence('clean', 'compile-ts', 'compile-ts-umd', cb); -}); +gulp.task('default', sequence('clean', 'compile-ts', 'compile-ts-umd')); gulp.task('dev', ['watch-ts']); diff --git a/package.json b/package.json index aaae2d2..17e5041 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "del": "latest", "gulp": "latest", "gulp-sequence": "latest", - "gulp-typescript": "latest", + "gulp-shell": "^0.6.5", "mocha": "latest", "should": "latest", "spec": "latest", @@ -58,4 +58,4 @@ "url": "https://github.com/taoqf/node-fast-html-parser/issues" }, "homepage": "https://github.com/taoqf/node-fast-html-parser" -} +} \ No newline at end of file