2 Star 0 Fork 0

迈科技/maikeji_analysis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gulpfile.js 5.44 KB
一键复制 编辑 原始数据 按行查看 历史
dylike 提交于 2017-01-05 12:41 . 更新微信分享的验证
// Generated on 2016-12-20 using generator-angular 0.15.1
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var openURL = require('open');
var lazypipe = require('lazypipe');
var rimraf = require('rimraf');
var wiredep = require('wiredep').stream;
var runSequence = require('run-sequence');
var rename = require('gulp-rename');
var yeoman = {
app: require('./bower.json').appPath || 'app',
dist: 'dist'
};
var paths = {
scripts: [yeoman.app + '/scripts/**/*.js'],
styles: [yeoman.app + '/styles/**/*.scss'],
test: ['test/spec/**/*.js'],
testRequire: [
yeoman.app + '/bower_components/angular/angular.js',
yeoman.app + '/bower_components/angular-mocks/angular-mocks.js',
yeoman.app + '/bower_components/angular-resource/angular-resource.js',
yeoman.app + '/bower_components/angular-cookies/angular-cookies.js',
yeoman.app + '/bower_components/angular-sanitize/angular-sanitize.js',
yeoman.app + '/bower_components/angular-route/angular-route.js',
'test/mock/**/*.js',
'test/spec/**/*.js'
],
karma: 'karma.conf.js',
views: {
main: yeoman.app + '/index.html',
files: [yeoman.app + '/views/**/*.html']
}
};
////////////////////////
// Reusable pipelines //
////////////////////////
var lintScripts = lazypipe()
.pipe($.jshint, '.jshintrc')
.pipe($.jshint.reporter, 'jshint-stylish');
var styles = lazypipe()
.pipe($.sass, {
outputStyle: 'expanded',
precision: 10
})
.pipe($.autoprefixer, '> 0%')
.pipe(gulp.dest, '.tmp/styles');
///////////
// Tasks //
///////////
gulp.task('styles', function () {
return gulp.src(paths.styles)
.pipe(styles());
});
gulp.task('lint:scripts', function () {
return gulp.src(paths.scripts)
.pipe(lintScripts());
});
gulp.task('clean:tmp', function (cb) {
rimraf('./.tmp', cb);
});
gulp.task('start:client', ['start:server', 'styles'], function () {
openURL('http://localhost:9000');
});
gulp.task('start:server', function () {
$.connect.server({
root: [yeoman.app, '.tmp'],
livereload: true,
// Change this to '0.0.0.0' to access the server from outside.
port: 9000,
middleware: function (connect, opt) {
return [['/bower_components',
connect["static"]('./bower_components')]]
}
});
});
gulp.task('start:server:test', function () {
$.connect.server({
root: ['test', yeoman.app, '.tmp'],
livereload: true,
port: 9001
});
});
gulp.task('watch', function () {
$.watch(paths.styles)
.pipe($.plumber())
.pipe(styles())
.pipe($.connect.reload());
$.watch(paths.views.files)
.pipe($.plumber())
.pipe($.connect.reload());
$.watch(paths.scripts)
.pipe($.plumber())
.pipe(lintScripts())
.pipe($.connect.reload());
$.watch(paths.test)
.pipe($.plumber())
.pipe(lintScripts());
gulp.watch('bower.json', ['bower']);
});
gulp.task('serve', function (cb) {
runSequence('clean:tmp',
['lint:scripts'],
['start:client'],
'watch', cb);
});
gulp.task('serve:prod', function () {
$.connect.server({
root: [yeoman.dist],
livereload: true,
port: 9000
});
});
gulp.task('test', ['start:server:test'], function () {
var testToFiles = paths.testRequire.concat(paths.scripts, paths.test);
return gulp.src(testToFiles)
.pipe($.karma({
configFile: paths.karma,
action: 'watch'
}));
});
// inject bower components
gulp.task('bower', function () {
return gulp.src(paths.views.main)
.pipe(wiredep({
directory: 'bower_components',
ignorePath: '..'
}))
.pipe(gulp.dest(yeoman.app));
});
///////////
// Build //
///////////
gulp.task('clean:dist', function (cb) {
rimraf('./dist', cb);
});
gulp.task('client:build', ['html', 'styles'], function () {
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
return gulp.src(paths.views.main)
.pipe($.useref({searchPath: [yeoman.app, '.tmp']}))
.pipe(jsFilter)
.pipe($.ngAnnotate())
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.minifyCss({cache: true}))
.pipe(cssFilter.restore())
.pipe($.rev())
.pipe($.revReplace())
.pipe(rename(function (path) {
if (path.extname === '.html') {
path.basename = 'index';
}
}))
.pipe(gulp.dest(yeoman.dist));
});
gulp.task('html', function () {
return gulp.src(yeoman.app + '/views/**/*')
.pipe(gulp.dest(yeoman.dist + '/views'));
});
gulp.task('images', function () {
return gulp.src(yeoman.app + '/images/**/*')
.pipe($.cache($.imagemin({
optimizationLevel: 5,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest(yeoman.dist + '/images'));
});
gulp.task('copy:extras', function () {
return gulp.src(yeoman.app + '/*', {dot: true})
.pipe(gulp.dest(yeoman.dist));
});
gulp.task('copy:fonts', function () {
return gulp.src(yeoman.app + '/fonts/**/*')
.pipe(gulp.dest(yeoman.dist + '/fonts'));
});
gulp.task('build', ['clean:dist'], function () {
runSequence(['images', 'copy:extras', 'copy:fonts', 'client:build']);
});
gulp.task('default', ['build']);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/maikeji/maikeji_analysis.git
git@gitee.com:maikeji/maikeji_analysis.git
maikeji
maikeji_analysis
maikeji_analysis
master

搜索帮助