代码拉取完成,页面将自动刷新
/* jshint node: true */
var join = require("path").join
var gulp = require('gulp'),
gutil = require('gulp-util'),
requirejs = require('gulp-requirejs'),
uglify = require('gulp-uglify'),
rename = require("gulp-rename"),
jshint = require('gulp-jshint'),
less = require('gulp-less'),
jade = require('gulp-jade'),
qunit = require('gulp-qunit'),
watch = require('gulp-watch'),
livereload = require('gulp-livereload'),
tinnylr = require('tiny-lr')
var server = tinnylr()
var exec = require("child_process").exec
var paths = {
distRoot: './build',
docsRoot: './docs',
demosRoot: './docs/demos'
}
var pkg = {
name: "bootstrap"
}
gulp.task('requirejs', function() {
//目前requirejs还不支持gulp.src
var jsDist = join(paths.distRoot, 'js')
var requirejsConfig= {
baseUrl: "js",
name: "almond",
optimize: "none",
include: pkg.name,
insertRequire: [pkg.name],
mainConfigFile: "js/requirejs-config.js",
out: pkg.name + '.js',
wrap: true
}
requirejs(requirejsConfig)
//uncompressed
.pipe(gulp.dest(jsDist))
//uglify
.pipe(uglify({preserveComments: 'some'}))
.pipe(rename(pkg.name + '.min.js'))
.pipe(gulp.dest(jsDist))
.pipe(livereload(server))
})
gulp.task('less', function() {
var cssDist = join(paths.distRoot, 'css')
var recess = function(input, output) {
output = output || input
gulp.src(join('less', input + '.less'))
.pipe(less())
.pipe(rename(output + '.css'))
.pipe(gulp.dest(cssDist))
.pipe(less({compress: true}))
.pipe(rename(output + '.min.css'))
.pipe(gulp.dest(cssDist))
.pipe(livereload(server))
}
recess('bootstrap')
recess('responsive', pkg.name + '-responsive')
})
// compile jade template
gulp.task('jade', function() {
gulp.src(['**/*.jade', '!base.jade', '!com-*', '!*-com.jade'], {cwd: join(paths.demosRoot, 'templates')})
.pipe(jade({pretty: true}))
.pipe(gulp.dest(paths.demosRoot))
.pipe(livereload(server))
})
//compile mastache template
gulp.task('hogan', function(callback) {
var child = exec('node docs/build', function(e) {
callback()
})
})
gulp.task('jshint', function() {
var jsfiles = [
'gulpfile.js',
'js/*.js',
'js/tests/unit/*.js'
]
gulp.src(jsfiles)
.pipe(jshint('js/.jshintrc'))
.pipe(jshint.reporter('default'))
})
gulp.task('qunit', function(callback) {
gulp.src('js/tests/*.html')
.pipe(qunit());
})
// copy fonts to build
gulp.task('fonts', function() {
gulp.src('./fonts/*')
.pipe(gulp.dest(join(paths.distRoot, 'fonts')))
})
gulp.task('watch', function() {
server.listen(3456)
gulp.watch('js/**/*.js', ['requirejs'])
gulp.watch('less/**/*.less', ['less'])
gulp.watch(join(paths.docsRoot, 'templates/**/*.mustache'), ['hogan'])
gulp.watch(join(paths.demosRoot, 'templates/**/*.jade'), ['jade'])
gulp.watch('./fonts/*', ['jade'])
})
gulp.task('test', ['jshint', 'qunit'])
gulp.task('docs', ['fonts', 'jade', 'hogan'])
gulp.task('default', ['less', 'test', 'requirejs', 'docs'])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。