闲情zhi

生活 创业 时评 杂文

gulp-changed gulp-sass only compile files that changed

these are some examples

uglifycss = require "gulp-uglifycss"
watch = require "gulp-watch"
changed = require "gulp-changed"

##编译scss文件
gulp.task 'sass', ->
  gulp.src "src/scss/**/*.scss"
  .pipe(changed("assets/css", {extension: ".min.css"}))   //this is right              {".css"} is wrong because i use rename ".min"
  .pipe(sass())
  .on "error", logError
  .pipe autoprefixer
  browsers: ['last 3 versions'],
     cascade: true, #是否美化属性值 默认:true 像这样:
     #-webkit-transform: rotate(45deg);
     # transform: rotate(45deg);
      remove:true #是否去掉不必要的前缀 默认:true
  .pipe uglifycss()
  .pipe rename suffix: '.min'
  .pipe gulp.dest 'assets/css'
  .pipe livereload()

#编译coffee文件
gulp.task "coffee", ->
  gulp.src "src/js/**/*.coffee", read:false
    .pipe(changed("assets/js", {extension: ".min.js"}))
    .pipe browserify
      debug: true
      transform: ['coffeeify']
      extensions: ['.coffee']
    .on "error", logError
    .pipe uglify()
    .pipe rename suffix: ".min"
    .pipe extReplace '.js'
    .pipe gulp.dest "assets/js"
    .pipe livereload()

#编译coffee文件
gulp.task "coffee", ->
  gulp.src "src/js/**/*.coffee", read:false
    .pipe(changed("assets/js", {extension: ".js"}))
    .pipe browserify
      debug: true
      transform: ['coffeeify']
      extensions: ['.coffee']
    .on "error", logError
    .pipe uglify()
    .pipe extReplace '.js'
    .pipe gulp.dest "assets/js"
    .pipe livereload()

If you have problem, leave your message

gulp-changed

发表评论

电子邮件地址不会被公开。