代码拉取完成,页面将自动刷新
var es = require('event-stream');
var gulp = require('gulp');
var concat = require('gulp-concat');
var connect = require('gulp-connect');
var templateCache = require('gulp-angular-templatecache');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var fs = require('fs');
var _ = require('lodash');
var scripts = require('./app.scripts.json');
var source = {
js: {
main: 'app/main.js',
src: [
// application config
'app.config.js',
// application bootstrap file
'app/main.js',
// main module
'app/app.js',
// module files
'app/**/module.js',
// other js files [controllers, services, etc.]
'app/**/!(module)*.js'
],
tpl: 'app/**/*.tpl.html'
}
};
var destinations = {
js: 'build'
};
gulp.task('build', function(){
return es.merge(gulp.src(source.js.src) , getTemplateStream())
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(concat('app.js'))
.pipe(gulp.dest(destinations.js));
});
gulp.task('js', function(){
return es.merge(gulp.src(source.js.src) , getTemplateStream())
.pipe(concat('app.js'))
.pipe(gulp.dest(destinations.js));
});
gulp.task('watch', function(){
gulp.watch(source.js.src, ['js']);
gulp.watch(source.js.tpl, ['js']);
});
gulp.task('connect', function() {
connect.server({
port: 8888
});
});
gulp.task('vendor', function(){
_.forIn(scripts.chunks, function(chunkScripts, chunkName){
var paths = [];
chunkScripts.forEach(function(script){
var scriptFileName = scripts.paths[script];
if (!fs.existsSync(__dirname + '/' + scriptFileName)) {
throw console.error('Required path doesn\'t exist: ' + __dirname + '/' + scriptFileName, script)
}
paths.push(scriptFileName);
});
gulp.src(paths)
.pipe(concat(chunkName + '.js'))
//.on('error', swallowError)
.pipe(gulp.dest(destinations.js))
})
});
gulp.task('prod', ['vendor', 'build']);
gulp.task('dev', ['vendor', 'js', 'watch', 'connect']);
gulp.task('default', ['dev']);
var swallowError = function(error){
console.log(error.toString());
this.emit('end')
};
var getTemplateStream = function () {
return gulp.src(source.js.tpl)
.pipe(templateCache({
root: 'app/',
module: 'app'
}))
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。