2016-12-14 85 views
0

我創建2任務,「compileApp」「compileAppDeploy」排除所有文件。基本上它們只是相似compileAppDeploy minify要部署的代碼。一飲而盡SRC不是從一個文件夾

獨立任務都運行良好,如果compileAppDeploy運轉,儘管第一再從DIST文件夾

未成功我試過幾個路徑的組合compileApp CONCAT精縮代碼。雖然如果我設置下面的路徑,然後javaScriptMinified.js將被刪除,但htmlAngularMinified.js將concated。

'!./app/dist/*.js 

目錄結構

+root 
     +app 
     +dist -> Exclude 
      -javaScriptMinified.js -> after run compileAppDeploy task 
      -htmlAngularMinified.js -> after run compileAppDeploy task 
     +filters -> Include 
     +l10n -> Exclude 
     +components -> Include 
     -app.js  -> Include 
     +css 
     -gulpfile.js 
     -index.html 
     -package.json 

compileApp

gulp.task('compileApp', function() { 

return gulp.src(['./app/app.js','./app/**/*.js','!./app/dist/']) 
    .pipe(plumber({errorHandler : onError})) 
    .pipe(concat('LoginPortal.min.js')) 
    .pipe(gulp.dest('./app/')); 

}); 

compileAppDeploy

gulp.task('compileAppDeploy', function(version) { 

return gulp.src(['./app/app.js','./app/**/*.js','!./app/dist/']) 
    .pipe(plumber({errorHandler : onError})) 
    .pipe(stripDebug()) 
    .pipe(uglify({ 
     warnings : false 
    })) 
    .pipe(replace('app/l10n' ,'' + version + '/l10n')) 
    .pipe(concat('LoginPortal' + version + '.min.js')) 
    .pipe(gulp.dest('./app/dist/' + version + '/')); 
}); 

回答

0

不成功我試了幾種路徑組合。雖然如果我設置路徑下面javaScriptMinified.js將被刪除,但htmlAngularMinified.js將被連接。

'!./app/dist/*.js 

你只在./app/dist/直接排除的文件,而不是在子目錄中。這可能意味着htmlAngularMinified.js在子目錄中,而javaScriptMinified.js則不在。

你需要從所有的目錄層次排除.js文件:!./app/dist/**/*.js

你不會有,如果你只是使用了正確的目錄結構不用擔心任何的。將你的發行目錄放在你的源代碼目錄中是一個糟糕的主意。

+root 
    +app 
     +dist 

使用以下結構:代替此結構的

+root 
    +app 
    +dist 

然後在你的compileAppDeploy你可以這樣做:

.pipe(gulp.dest('./dist/' + version + '/')); 

而且你不必擔心不包括dist個目標,因爲它不再低於./app