gulp = require "gulp"jshint = require "gulp-jshint"concat = require "gulp-concat"uglify = require "gulp-uglify"gulptask "script"->gulpsrc "xxx""yyy"pipe jshintpipe concat "base.min.js"pipe uglify # 混淆pipe gulpdest "输出目录"
gulp = require "gulp"jshint = require "gulp-jshint"rename = require "gulp-rename"uglify = require "gulp-uglify"sourcemaps = require "gulp-sourcemaps"gulptask "script"->gulpsrc "xxx.js""!xxx.min.js""yyy.js""!yyy.min.js"pipe sourcemapsinitpipe jshintpipe renameextname: ".min.js"pipe uglifymangle: no # 不混淆pipe sourcemapswrite "./"pipe gulpdest "./"
path = require "path"gulp = require "gulp"plumber = require "gulp-plumber"jshint = require "gulp-jshint"rename = require "gulp-rename"uglify = require "gulp-uglify"rev = require "gulp-rev"gulptask "script"->gulpsrc "xxxx.js""!xxx.min.js"pipe plumberpipe jshintpipe renameextname: ".min.js"pipe uglifymanagle: nopipe rev # 加版本号pipe gulpdest "压缩文件"pipe revmanifest # 这部分解决 js html 同时压缩时映射文件被覆盖问题path : pathjoin __dirname"映射文件目录//rev-manifest.json"cwd : pathjoin __dirname"映射文件目录"merge : yespipe gulpdest "版本文件输出目录"
gulp = require "gulp"rename = require "gulp-rename"cssImport = require "gulp-cssimport"cssmin = require "gulp-cssmin"gulptask "css"->gulpsrc "xxx""yyy"pipe renameextname: ".min.css"pipe cssImportpipe cssmincompatibility: "ie7"pipe gulpdest "输出目录"
gulp = require "gulp"plumber = require "gulp-plumber"htmlmin = require "gulp-htmlmin"rename = require "gulp-rename"gulptask "html"->options =removeComments : false # 清除HTML注释collapseWhitespace : true # 压缩HTMLcollapseBooleanAttributes : true # 省略布尔属性的值 <input checked="true"/> ====> <input />removeEmptyAttributes : true # 删除所有空格作属性值 <input id="" /> ====> <input />removeScriptTypeAttributes : true # 删除<script>的type="text/javascript"removeStyleLinkTypeAttributes : true # 删除<style>和<link>的type="text/css"minifyJS : true # 压缩页面JSminifyCSS : true # 压缩页面CSSgulpsrc "xxx/**/*.html""!xxx/**/*.min.html"pipe plumber # 出错不跳出pipe htmlmin optionspipe renameextname: ".min.html"pipe gulpdest "输出目录"
path = require "path"gulp = require "gulp"plumber = require "gulp-plumber"htmlmin = require "gulp-htmlmin"rename = require "gulp-rename"rev = require "gulp-rev"gulptask "html"->options =removeComments : false # 清除HTML注释collapseWhitespace : true # 压缩HTMLcollapseBooleanAttributes : true # 省略布尔属性的值 <input checked="true"/> ====> <input />removeEmptyAttributes : true # 删除所有空格作属性值 <input id="" /> ====> <input />removeScriptTypeAttributes : true # 删除<script>的type="text/javascript"removeStyleLinkTypeAttributes : true # 删除<style>和<link>的type="text/css"minifyJS : true # 压缩页面JSminifyCSS : true # 压缩页面CSSgulpsrc "xxx/**/*.html""!xxx/**/*.min.html"pipe plumber # 出错不跳出pipe htmlmin optionspipe renameextname: ".min.html"pipe revpipe gulpdest "压缩文件输出目录"pipe revmanifestpath : pathjoin __dirname"映射文件输出目录/rev-manifest.json"cwd : pathjoin __dirname"映射文件输出目录"merge : yespipe gulpdest "版本文件输出目录"
基本上平时会用到的功能都覆盖到了,高级用法控制文件流的找时间再整理整理