我的gulp.js清單

來源:互聯網
上載者:User

標籤:本地   progress   bug   pre   cto   log   server   root   主目錄   

var gulp = require(‘gulp‘),        cssmin = require(‘gulp-clean-css‘), //壓縮css檔案        concat = require(‘gulp-concat‘), //合并js檔案        jsmin = require(‘gulp-uglify‘), //壓縮js檔案        imgmin = require(‘gulp-imagemin‘), //圖片壓縮        rename = require(‘gulp-rename‘), //檔案重新命名        jshint = require(‘gulp-jshint‘), //js檔案檢查        rev = require(‘gulp-rev‘), //- 對檔案名稱加MD5尾碼        revCollector = require(‘gulp-rev-collector‘), //路徑替換        connect = require(‘gulp-connect‘); //配置本機伺服器//#########檔案監聽及自動重新整理網頁start#################gulp.task(‘connect‘, function () {    connect.server({        host: ‘localhost‘, //地址,可不寫,不寫的話,預設localhost        port: 3000, //連接埠號碼,可不寫,預設8000        root: ‘./‘, //當前項目主目錄        livereload: true //自動重新整理    });});gulp.task(‘html‘, function () {    gulp.src(‘./bill/*.html‘)            .pipe(connect.reload());});gulp.task(‘watch‘, function () {    gulp.watch(‘./bill/css/*.css‘, [‘html‘]); //監控css檔案    gulp.watch(‘./bill/js/*.js‘, [‘html‘]); //監控js檔案    gulp.watch([‘./bill/*.html‘], [‘html‘]); //監控html檔案});gulp.task(‘server‘, [‘connect‘, ‘watch‘]);//#########檔案監聽及自動重新整理網頁end #################gulp.task(‘Cssmin‘, function () {    gulp.src("bill/css/common.css")            .pipe(rename({suffix: ‘.min‘}))            .pipe(cssmin({dubug: true}, function (details) {                console.log(details);                console.log(details.name + ‘(originalSize): ‘ + details.stats.originalSize);                console.log(details.name + ‘(minifiedSize): ‘ + details.stats.minifiedSize);            }))            .pipe(rev())            .pipe(gulp.dest("bill/css"))            .pipe(rev.manifest()) //- 產生一個rev-manifest.json            .pipe(gulp.dest(‘bill/css‘));});gulp.task(‘Jsmin‘, function () {    gulp.src("bill/js/common.js")            .pipe(rename({suffix: ‘.min‘}))            .pipe(jsmin())            .pipe(rev())            .pipe(gulp.dest("bill/js"))            .pipe(rev.manifest()) //- 產生一個rev-manifest.json            .pipe(gulp.dest(‘bill/js‘));});gulp.task(‘Imgmin‘, function () {    gulp.src("src/img/*.jpg")            .pipe(imgmin({                optimizationLevel: 5, //類型:Number  預設:3  取值範圍:0-7(最佳化等級)                progressive: true, //類型:Boolean 預設:false 無損壓縮jpg圖片                interlaced: true, //類型:Boolean 預設:false 隔行掃描gif進行渲染                multipass: true //類型:Boolean 預設:false 多次最佳化svg直到完全最佳化            }))            .pipe(gulp.dest("dist/img"));});gulp.task(‘rev‘, function () {    gulp.src([‘./bill/**/*.json‘, "./bill/index.html"])//- 讀取 rev-manifest.json 檔案以及需要進行替換的檔案            .pipe(revCollector(                    {                        replaceReved: true,                        dirReplacements: {                            ‘css‘: ‘css‘,                            ‘js‘: ‘js‘                        }                    }            ))//- 執行檔案名稱的替            .pipe(gulp.dest(‘./bill‘)); //- 替換後的檔案輸出的目錄});//執行配置任務gulp.task(‘default‘, [‘Cssmin‘, ‘Jsmin‘, "rev"], function () {    // gulp.start(‘testJsmin‘);});

  

我的gulp.js清單

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.