gulp-delete-lines
v0.0.7
Published
A gulp plugin that will delete all lines that matches one of the given regex filters.
Downloads
11,071
Maintainers
Readme
gulp-delete-lines
A gulp plugin that will delete all lines that matches one of the given regex filters.
Notes
With respect to Rolf Erik Lekangs work but now with minor bug fixes.
Install
Install with npm
npm install --save-dev gulp-delete-lines
Examples
Our index.html file:
<!doctype html>
<html>
<head>
<title>Our App</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" type="text/css" href="vendor/normalize.css/normalize.css" />
<link rel="stylesheet" type="text/css" href="vendor/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="assets/sass/desktop.css" />
</head>
<body ng-controller="AppController">
<div>
markup goes here...
</div>
<script type="text/javascript" src="vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="vendor/angular/angular.min.js"></script>
<script type="text/javascript" src="app/app_Desktop.js"></script>
<script type="text/javascript">
angular.bootstrap(document, ['ourApp']);
</script>
</body>
</html>
Example 1: Removes all script tags in index.html
var gulp = require('gulp');
var deleteLines = require('gulp-delete-lines');
gulp.task('remove-scripts', function () {
gulp.src('./build/index.html')
.pipe(deleteLines({
'filters': [
/<script\s+type=["']text\/javascript["']\s+src=/i
]
}))
.pipe(gulp.dest('dist'));
});
Example 2: Removes all style tags in index.html
var gulp = require('gulp');
var deleteLines = require('gulp-delete-lines');
gulp.task('remove-styles', function () {
gulp.src('./build/index.html')
.pipe(deleteLines({
'filters': [
/<link\s+rel=["']/i
]
}))
.pipe(gulp.dest('dist'));
});
License
MIT © Carsten Schaefer