在一饮而尽任务您覆盖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")
...
如果试图为每个任务指定不同的TARGETPATH,它的工作原理? – clemkoa
@clemkoa你的意思是代码中的第24行被写入所有的任务,而不是全局引用它? –