简体   繁体   English

如何删除生产分支中的所有评论

[英]how to remove all comments in production branch

I have two environments: main branch and production branch.我有两个环境:主分支和生产分支。 The problem is that I have a lot of comments in every line of code and I want to remove them in the production branch.问题是我在每一行代码中都有很多注释,我想在生产分支中删除它们。 I tried cleaning the comments manually for production, but after I make some changes in the main branch and merge to production, all the comments are back.我尝试手动清理评论以进行生产,但是在主分支中进行一些更改并合并到生产后,所有评论都回来了。 Is there any way to remove all the comments in the production branch?有没有办法删除生产分支中的所有评论?

hey if u are using babel cli u can remove comments by updating.babelrc config嘿,如果你使用的是 babel cli,你可以通过 update.babelrc 配置删除评论

{comments: false}

or u can pass it like this while building或者你可以在构建时像这样传递它

"build": "babel ./index.js --out-dir ./dist/index.js --no-comments"

and if u want to use gulp如果你想使用 gulp

you can use gulp-strip-comments你可以使用 gulp-strip-comments

var gulp = require('gulp');
var strip = require('gulp-strip-comments');

gulp.task('default', function () {
  return gulp.src('template.js')
    .pipe(strip())
    .pipe(gulp.dest('dist'));
});
 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM