1 Star 0 Fork 9

XLONG/nzh

forked from 含浪/nzh 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gulpfile.js 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
含浪 提交于 2018-07-25 13:41 . up build
var path = require("path");
var gulp = require("gulp");
var mocha = require("gulp-mocha");
var mochaPhantomjs = require("gulp-mocha-phantomjs");
var browserify = require("gulp-browserify");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var header = require("gulp-header");
var rollup = require("rollup");
var commonjs = require("rollup-plugin-commonjs");
var resolve = require("rollup-plugin-node-resolve");
// var istanbul = require("gulp-istanbul");
var package = require("./package.json");
var banner =
'/*!\n' +
' * ' + package.name + ' v' + package.version + '\n' +
' * Homepage ' + package.homepage + '\n' +
' * License ' + package.license + '\n' +
' */\n'
var outputDir = 'dist/'
gulp.task('build', ['test-server','rollup','min'], function () {
// return gulp.src('./browser-source/*.js')
// .pipe(browserify())
// .pipe(header(banner))
// .pipe(gulp.dest('./dist'))
// .pipe(uglify())
// .pipe(header(banner))
// .pipe(rename({
// suffix:".min"
// }))
// .pipe(gulp.dest('./dist'));
// return rollup.rollup({
// input: './nzh.js',
// plugins: [
// resolve(),
// commonjs()
// ]
// }).then(function (bundle) {
// return bundle.write({
// file: './dist1/nzh.js',
// format: 'umd',
// name: 'Nzh',
// banner: banner,
// sourcemap: false
// })
// })
})
function runRollup(input, output) {
var inputopt = {
// input: './nzh.js',
plugins: [
resolve(),
commonjs()
]
}
var outputopt = {
// file: './dist/nzh.js',
format: 'umd',
name: 'Nzh',
banner: banner,
sourcemap: false
}
return rollup.rollup(Object.assign({},inputopt,{
input: input
})).then(function (bundle) {
return bundle.write(Object.assign({},outputopt,{
file: output,
}))
})
}
gulp.task('rollup', function () {
return Promise.all([
runRollup('./nzh.js',outputDir + 'nzh.js'),
runRollup('./cn.js',outputDir + 'nzh.cn.js'),
runRollup('./hk.js',outputDir + 'nzh.hk.js'),
])
})
gulp.task('min',['rollup'],function () {
return gulp.src(['dist/!(*.min).js'])
.pipe(uglify())
.pipe(header(banner))
.pipe(rename({
suffix:".min"
}))
.pipe(gulp.dest(outputDir));
})
// gulp.task('pre-test', function () {
// return gulp.src(['src/**/*.js'])
// // Covering files
// .pipe(istanbul())
// // Force `require` to return covered files
// .pipe(istanbul.hookRequire());
// });
// gulp.task('test', ['pre-test'], function () {
// return gulp.src('test/mocha_*.js', {read: false})
// .pipe(mocha({reporter: 'dot'}))
// // Creating the reports after tests ran
// .pipe(istanbul.writeReports())
// // Enforce a coverage of at least 90%
// .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
// });
gulp.task('test', ['test-server', 'test-browser'])
gulp.task('test-server', function () {
return gulp.src('test/test_mocha.js', { read: false })
.pipe(mocha({ reporter: 'dot' }))
});
gulp.task('output-testjs-browser', ['test-server'], function () {
return gulp.src('test/test_mocha.js')
.pipe(browserify({ insertGlobals: true }))
.pipe(rename({
basename: "tests"
}))
.pipe(gulp.dest('test/browser'));
})
gulp.task('test-browser', ['output-testjs-browser', 'build'], function () {
return gulp.src('test/browser/test.html')
.pipe(mochaPhantomjs({ reporter: 'dot' }))
})
gulp.task('test-docs', ['build'], function () {
})
gulp.task('default', ['build', 'test']);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/lixianglong3210/nzh.git
[email protected]:lixianglong3210/nzh.git
lixianglong3210
nzh
nzh
master

搜索帮助