node.js - Inconsistent Results with Running Gulp from Visual Studio on Post Build -
i'm running gulp 3.9.0 , calling gulp commands visual studio 2013. flow such whenever build in vs, gulp should clean temporary , output files, after successful build, compile javascript assets 1 file.
the problem that, i've noticed after running "gulp build", assets not generated @ all. happens on command line. after running "gulp clean" (which removes output), have run "gulp build" twice see output materialize. it's if gulp failing silently. not sure if issue node running on windows or if have misconfigured something.
note vs responsible compiling typescript files single .js in \output folder.
apologies in advanced if there better way i'm trying do. still gulp/node newbie.
vs pre-build:
gulp clean vs post-build:
gulp build gulpfile.js:
var gulp = require('gulp'); var del = require('del'); var concat = require('gulp-concat'); var ngannotate = require('gulp-ng-annotate'); var uglify = require('gulp-uglify'); var templatecache = require('gulp-angular-templatecache'); var concatcss = require('gulp-concat-css'); var minifycss = require('gulp-minify-css'); gulp.task("cleanoutdatedlibraries", function(){ del("./libs/*"); del(['./myapp.js', './myapp.min.js', './myapp.css']) }); gulp.task("cleantemporaryfiles", function(){ del("./output/*"); }); /** run gulp clean on prebuild */ gulp.task('clean', ["cleanoutdatedlibraries", "cleantemporaryfiles"]) gulp.task('copynewestlibraries', function(){ var bowerfiles = ['angular/angular.min.js', 'angular/angular.js', 'angular/angular.min.js.map', 'angular-ui-router/release/angular-ui-router.min.js', 'angular-local-storage/dist/angular-local-storage.min.js', 'jquery/dist/jquery.min.js', 'jquery/dist/jquery.min.map', 'lodash/lodash.min.js', 'angular-resource/angular-resource.min.js', 'angular-resource/angular-resource.min.js.map', 'momentjs/min/moment.min.js', 'angular-loading-bar/src/loading-bar.js', 'ngdialog/js/ngdialog.min.js']; gulp.src(bowerfiles, {cwd: "./bower_components/"}) .pipe(gulp.dest('./libs')); }); gulp.task('copythirdpartylibraries', function(){ var thirdpartyfiles = ['jquery-ui.min.js', 'angular-sanitize.min.js']; gulp.src(thirdpartyfiles, {cwd: "./_thirdparty/"}) .pipe(gulp.dest('./libs')); }); /** merge angular js html templates cache */ gulp.task('mergehtmltemplatesintoangularcache', function(){ gulp.src('app/**/*.html') .pipe(templatecache("templates.js", { module: "myapp" })) .pipe(gulp.dest('./output/')); }); gulp.task('produceminfiedapp', function(){ gulp.src(['app/**/*.js', 'output/typescripts.js']) .pipe(concat('bundle.min.js')) .pipe(ngannotate()) .pipe(uglify()) .pipe(gulp.dest('./output/')); gulp.src(['output/bundle.min.js', 'output/templates.js']) .pipe(concat('myapp.min.js')) .pipe(gulp.dest('./')); }); gulp.task('produceapp', function(){ gulp.src(['app/**/*.js', 'output/typescripts.js']) .pipe(concat('bundle.js')) .pipe(ngannotate()) .pipe(gulp.dest('./output/')); gulp.src(['output/bundle.js', 'output/templates.js']) .pipe(concat('myapp.js')) .pipe(gulp.dest('./')); }); gulp.task('mergestyles', function(){ gulp.src(['styles/**/*.css']) .pipe(concat('styles.css')) .pipe(gulp.dest("./output/")); gulp.src(['app/**/*.css']) .pipe(concat('app.css')) .pipe(gulp.dest("./output/")); gulp.src(['output/styles.css', 'output/app.css']) .pipe(concatcss("./myapp.css")) .pipe(minifycss({compatibility: 'ie10'})) .pipe(gulp.dest('./')); }); /** run gulp build on post build */ gulp.task('build', ["copynewestlibraries", "copythirdpartylibraries", "mergehtmltemplatesintoangularcache", "produceminfiedapp", "produceapp", "mergestyles"]);
/** run gulp build on post build */ gulp.task('build', ["copynewestlibraries", "copythirdpartylibraries", "mergehtmltemplatesintoangularcache", "produceminfiedapp", "produceapp", "mergestyles"]); these tasks (copynewestlibraries, produceapp, etc.) run asynchronously, in no particular order. e.g. produceapp may finish before copynewestlibraries, not want.
see how run gulp tasks sequentially 1 after other more info.
Comments
Post a Comment