如何从以前的打字稿(.ts)文件中删除编译的JS文件? [英] How to delete compiled JS files from previous typescript(.ts) files?

查看:480
本文介绍了如何从以前的打字稿(.ts)文件中删除编译的JS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循 Angular 2快速入门教程。以下是我的文件夹结构 -

I am following Angular 2 quick start tutorial. Following is my folder structure -

├── gulpfile.js
├── index.html
├── js
|   ├── app.component.js
|   └── boot.js
├── source
|   ├── app.component.ts
|   └── boot.ts
├── node_modules
    ├── module 1
    └── module 2

我的打字稿文件位于 source / 目录中。我将它编译为 js / 目录。我使用的是gulp-typescript。

My typescript files are in source/ directory. I'm compiling it to js/ directory. I'm using gulp-typescript.

问题是,当我重新命名文件 boot.ts bootstrap.ts 并重新编译,创建相应的 bootstrap.js 文件,但是旧的 boot.js 文件仍然保留在js /目录中。

The problem is when I, for example, rename the file boot.ts to bootstrap.ts and compile again, corresponding bootstrap.js file is created but the old boot.js file still remains in the js/ directory.

现在文件夹结构如下所示 -

Now the folder structure looks like following-

├── gulpfile.js
├── index.html
├── js
|   ├── app.component.js
|   └── bootstrap.js
|   └── boot.js
├── source
|   ├── app.component.ts
|   └── bootstrap.ts
├── node_modules
    ├── module 1
    └── module 2

我想通过gulp任务自动删除这个 boot.js 。如何实现这一点?

I want to delete this boot.js autonomically via gulp task. How to achieve this?

推荐答案

安装gulp del。

Install gulp del.

$ npm install --save-dev gulp del

创建任务。

var gulp = require('gulp');
var del = require('del');

gulp.task('clean:output', function () {
  return del([
    'js/'
  ]);
});

gulp.task('default', ['clean:output']);

您可以在gulp del 这里

You can find more info on gulp del here.

这篇关于如何从以前的打字稿(.ts)文件中删除编译的JS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆