Im having a problem with gulp. Im using gulp-watch and gulp-ruby-sass to compile the scss files when something changes, the problem is, im changing just one file and compiles all the files on the folder, and a I just want to compile the file that changed. I tried to use the plugin gulp-changed but got the same result.
Asked
Active
Viewed 3,563 times
2 Answers
0
Assuming that you compile one scss file to another css file (for example header.scss to header.css), you can use gulp-newer to compile only the changed file:

cimmanon
- 67,211
- 17
- 165
- 171

Mario Araque
- 4,562
- 3
- 15
- 25
-
1Can you be more verbose, please? Any working example? I've been trying to use gulp-newer with sass files, but I was not able to achieve the effect that @Naccarati is asking about. – piotr.d Apr 20 '15 at 11:52
-
@piotr.d my answer [here](http://stackoverflow.com/a/31844630/335880) might help you, if you haven't gotten this working yet. – Adrian Günter Aug 05 '15 at 23:52
-1
you can use gulp-changed
this is my example http://lizhug.com/tech/gulp-changed-gulp-sass-only-compile-files-that-changed/
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 像这样:
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()

user2538840
- 47
- 1
- 1
- 8