-
Notifications
You must be signed in to change notification settings - Fork 7
Home
Gulp plug-in minifying PHP source code by removing comments and whitespace.
Install the latest version of Gulp-PHP-Minify with npm package manager:
npm install @cedx/gulp-php-minify
For detailed instructions, see the installation guide.
If you haven't used Gulp before, be sure to check out the related documentation, as it explains how to create a gulpfile.js
, as well as install and use plug-ins.
Once you're familiar with that process, you may install the plug-in.
The plug-in takes a list of PHP scripts as input, and removes the comments and whitespace in these files by applying the php_strip_whitespace()
function on their contents:
import gulp from "gulp";
import phpMinify from "@cedx/gulp-php-minify";
export function compressPhp() {
return gulp.src("path/to/**/*.php", {read: false})
.pipe(phpMinify())
.pipe(gulp.dest("path/to/out"));
}
Caution: the plug-in only needs the file paths, so you should specify the
read
option tofalse
when providing the file list, and you should not have any other plug-in before it.