2016-02-26 67 views
0

我正在创建一个ghost(http://ghost.io)主题并将目录放置在C:/www/megane_theme中,而我的目标文件夹位于C:/www/megane.local/contents/theme/megane事情是,当我单独运行gulp时,它会写入目标文件夹就好了。但是当它观察到任何更改时,它会响应更改(显示任务运行的控制台notif),但目标文件未写入。没有写入目标文件夹的Coffee Gulp文件在监视任务

只是为了说明为什么我的源文件距离目标文件太远,似乎我在键入bower install时已经优先考虑来自ghost的bower,并且即使我在ghost文件夹内的源目录中明确键入bower install bower.json也是如此。为了避免这个问题,我将它从ghost文件夹移开,并拥有自己的文件夹。

这里是供参考的gulp文件。

https://gist.github.com/abarcenas29/88bcd0dd00d3aa941924

+0

如果试图为每个任务指定不同的TARGETPATH,它的工作原理? – clemkoa

+0

@clemkoa你的意思是代码中的第24行被写入所有的任务,而不是全局引用它? –

回答

0

在一饮而尽任务您覆盖targetPath

任务sass第一次运行后全局变量targetPath有新值:/www/megane.local/content/themes/megane/assets/css

下一个任务:angular。全局变量targetPath的值为/www/megane.local/content/themes/megane/assets/css/assets/js

解决方法很简单:不会覆盖全局变量targetPath

... 

gulp.task "sass", -> 
    sourcePath = "styles/template/**/*.sass" 
    sass(sourcePath,{sourcemap:true}) 
    .pipe(plumber()) 
    .on('error',sass.logError) 
    .pipe(prefixer()) 
    .pipe(minfiyCss()) 
    .pipe(gulp.dest(path.join targetPath,"assets","css")) 

... 

gulp.task "angular", -> 
    sourcePath = [ 
    "angular/config/*.coffee" 
    "angular/services/**/*.coffee" 
    "angular/directives/**/*.coffee" 
    "angular/controllers/**/*.coffee" 
    ] 
    gulp.src(sourcePath) 
     .pipe(plumber()) 
     .pipe(coffee {bare:true}) 
     .pipe(ngAnnotate {single_quotes:true}) 
     .pipe(sourcemap.init {loadMaps: true}) 
     .pipe(concat 'angular.min.js') 
     .pipe(uglify()) 
     .pipe(sourcemap.write()) 
     .pipe(gulp.dest path.join targetPath,"assets","js") 

...