2015-12-10 16:22:20 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var path = require('path');
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var conf = require('./conf');
|
|
|
|
|
|
|
|
var $ = require('gulp-load-plugins')();
|
|
|
|
|
|
|
|
var wiredep = require('wiredep').stream;
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
2015-12-14 18:22:38 +00:00
|
|
|
var browserSync = require('browser-sync');
|
|
|
|
|
2016-01-12 16:35:53 +00:00
|
|
|
gulp.task('inject-reload', ['inject'], function () {
|
2015-12-14 18:22:38 +00:00
|
|
|
browserSync.reload();
|
|
|
|
});
|
|
|
|
|
2016-02-24 13:07:13 +00:00
|
|
|
gulp.task('inject', ['scripts', 'styles', 'injectAuth', 'inject404', 'copyVendorImages'], function () {
|
2015-12-10 16:22:20 +00:00
|
|
|
var injectStyles = gulp.src([
|
2016-01-12 16:35:53 +00:00
|
|
|
path.join(conf.paths.tmp, '/serve/app/main.css'),
|
2015-12-10 16:22:20 +00:00
|
|
|
path.join('!' + conf.paths.tmp, '/serve/app/vendor.css')
|
2016-01-12 16:35:53 +00:00
|
|
|
], {read: false});
|
2015-12-10 16:22:20 +00:00
|
|
|
|
|
|
|
var injectScripts = gulp.src([
|
2015-12-14 21:50:54 +00:00
|
|
|
path.join(conf.paths.src, '/assets/js/**/*.js'),
|
2015-12-10 16:22:20 +00:00
|
|
|
path.join(conf.paths.src, '/app/**/*.module.js'),
|
|
|
|
path.join(conf.paths.src, '/app/**/*.js'),
|
|
|
|
path.join('!' + conf.paths.src, '/app/**/*.spec.js'),
|
|
|
|
path.join('!' + conf.paths.src, '/app/**/*.mock.js'),
|
|
|
|
])
|
2016-01-12 16:35:53 +00:00
|
|
|
/*.pipe($.angularFilesort())*/.on('error', conf.errorHandler('AngularFilesort'));
|
2015-12-10 16:22:20 +00:00
|
|
|
|
|
|
|
var injectOptions = {
|
|
|
|
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
|
|
|
|
addRootSlash: false
|
|
|
|
};
|
|
|
|
|
2016-01-12 16:35:53 +00:00
|
|
|
return gulp.src(path.join(conf.paths.src, '/index.html'))
|
2015-12-10 16:22:20 +00:00
|
|
|
.pipe($.inject(injectStyles, injectOptions))
|
|
|
|
.pipe($.inject(injectScripts, injectOptions))
|
|
|
|
.pipe(wiredep(_.extend({}, conf.wiredep)))
|
|
|
|
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
|
|
|
|
});
|
2016-01-12 16:35:53 +00:00
|
|
|
|
|
|
|
gulp.task('injectAuth', ['stylesAuth'], function () {
|
|
|
|
return injectAlone({
|
|
|
|
css: [path.join('!' + conf.paths.tmp, '/serve/app/vendor.css'), path.join(conf.paths.tmp, '/serve/app/auth.css')],
|
|
|
|
paths: [path.join(conf.paths.src, '/auth.html'), path.join(conf.paths.src, '/reg.html')]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('inject404', ['styles404'], function () {
|
|
|
|
return injectAlone({
|
|
|
|
css: [path.join('!' + conf.paths.tmp, '/serve/app/vendor.css'), path.join(conf.paths.tmp, '/serve/app/404.css')],
|
|
|
|
paths: path.join(conf.paths.src, '/404.html')
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
var injectAlone = function (options) {
|
|
|
|
var injectStyles = gulp.src(
|
|
|
|
options.css
|
|
|
|
, {read: false});
|
|
|
|
|
|
|
|
var injectOptions = {
|
|
|
|
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
|
|
|
|
addRootSlash: false
|
|
|
|
};
|
|
|
|
|
|
|
|
return gulp.src(options.paths)
|
|
|
|
.pipe($.inject(injectStyles, injectOptions))
|
|
|
|
.pipe(wiredep(_.extend({}, conf.wiredep)))
|
|
|
|
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
|
|
|
|
};
|