gulp compress js, html, css

var gulp = require('gulp') //Since require returns an object, the gulp object will have some methods and attributes
var htmlmin = require('gulp-htmlmin')
var jsmin = require('gulp-uglify' )
var cssmin = require('gulp-minify-css')
//Bear the brunt: task method
//Two parameters 1. Task name [arbitrary string] 2. It is the callback function -> enter the gulp task name in the black window to run the callback function

gulp.task('default',function(){ //If the task name is default, you can directly enter gulp to run back the function
gulp.src()//Indicate the path where the file you want to compress is located
gulp.dest() / /The location of the compressed
file.pipe() //
var options = {
removeComments: true,//Clear HTML comments
collapseWhitespace: true,//Compress HTML
collapseBooleanAttributes: true,//Omit the value of Boolean attributes ==>
removeEmptyAttributes: true,//remove all spaces as attribute values ​​==>
removeScriptTypeAttributes: true,//delete

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324720961&siteId=291194637