1 Star 0 Fork 5

Enock/PathFinding

forked from 瞌睡游鱼/PathFinding 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.js 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
'use strict';
const gulp = require("gulp");
const concat = require("gulp-concat");
const minify = require('gulp-minify');
const fs = require('fs');
const path = require("path");
function readDir(basePath, extension) {
let outs = [];
let files = fs.readdirSync(basePath);
files.forEach((fileName) => {
var fullname = path.join(basePath, fileName);
var stats = fs.statSync(fullname);
if (stats.isDirectory()) {
let childOuts = readDir(fullname, extension);
outs = outs.concat(childOuts);
} else if (extension && fullname.lastIndexOf(extension) != -1) {
outs.push(fullname);
}
})
return outs;
}
const ts = require('gulp-typescript');
const footer = require("gulp-footer");
const gulpIf = require("gulp-if");
const header = require("gulp-header");
const replace = require("gulp-replace");
const sourcemaps = require('gulp-sourcemaps');
let pkg = JSON.parse(fs.readFileSync("./package.json").toString());
var version = pkg.version;
var vTime = Date.now();
let allModule = [];
buildModel("astar", true);
buildModel("jump", true);
gulp.task('default', gulp.series(...allModule));
function buildModel(modelName, isBase) {
let modelProject = ts.createProject(`tsconfig/tsconfig_${modelName}.json`);
gulp.task(modelName, () => {
let tscVinyl = modelProject.src()
.pipe(sourcemaps.init())
.pipe(modelProject())
tscVinyl.dts
.pipe(header(`//版本号${version},编译时间${(new Date()).toString()}\r\n`))
.pipe(gulp.dest("./"))
return tscVinyl.js
.pipe(replace('"use strict";', ''))
.pipe(replace('var PF;', ''))
.pipe(header(isBase ? `PF.version="${version}";PF.vTime=${vTime};` : `PF.${modelName}Ver={"version":"${version}","vTime":${vTime}};`))
.pipe(header(`\'use strict\'\nvar PF = window.PF = window.PF || {};\n`))
.pipe(sourcemaps.write('./'))
.pipe(minify({ ext: { min: ".min.js" } }))
.pipe(gulp.dest("./"))
})
// gulp.task(modelName + "Ts", () => {
// return modelProject.src()
// .pipe(modelProject()).dts
// .pipe(header(`//版本号${version},编译时间${(new Date()).toString()}\r\n`))
// .pipe(gulp.dest("./"));
// });
allModule.push(modelName);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/yuanxiaoyu/path-finding.git
[email protected]:yuanxiaoyu/path-finding.git
yuanxiaoyu
path-finding
PathFinding
master

搜索帮助