diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 187f55224..83cf0ac44 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -23,6 +23,7 @@ import proxy from 'proxy-middleware'; import urlparser from 'url'; import cachebust from 'gulp-cache-bust'; import bower from 'gulp-bower'; +import runSequence from 'run-sequence'; let args = yargs.argv; let env = args.env || 'prod'; @@ -55,6 +56,8 @@ let redirect = (route) => { } }; +let min = (env === 'dev') ? '' : '.min'; + // Lint Task gulp.task('lint', () => gulp.src(angularAppLocation) @@ -95,19 +98,22 @@ gulp.task('less', () => gulp.task('bower-install', () => bower() ); -gulp.task('inject', ['bower-install'], () => { - - var min = (env === 'dev') ? '' : '.min'; +gulp.task('inject:files', () => + gulp.src(bowerFiles({checkExistence : true, read: true, debugging : false, env : env}), {base: 'bower_components'}) + .pipe(gulp.dest(appLocation + 'lib/')) +); +gulp.task('inject:index', () => gulp.src(indexLocation) .pipe(inject(gulp.src(bowerFiles({read: false, debugging : false, env : env})), { addRootSlash : false, ignorePath : "/bower_components/", addPrefix : "app/lib"})) .pipe(inject(gulp.src(appFiles).pipe(rename({suffix : min})), {addRootSlash : false, ignorePath : staticLocation , name: 'app'})) - .pipe(cachebust({ type : 'MD5'})) + .pipe(cachebust({ type : 'MD5', basePath : staticLocation})) .pipe(gulp.dest(staticLocation)) - .pipe(connect.reload()); + .pipe(connect.reload()) +); - gulp.src(bowerFiles({checkExistence : true, read: true, debugging : false, env : env}), {base: 'bower_components'}) - .pipe(gulp.dest(appLocation + 'lib/')); +gulp.task('inject', ['bower-install'], (cb) => { + return runSequence('inject:files', 'inject:index', cb); }); gulp.task('web-server', () => { diff --git a/package.json b/package.json index 6bb14246e..254d0912d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "devDependencies": { "gulp-connect": "^2.2.0", "gulp-jshint": "^1.10.0", - "proxy-middleware": "^0.11.0" + "proxy-middleware": "^0.11.0", + "run-sequence": "^1.1.4" }, "repository": { "type": "git",