分离dev-server和类型校验,清理构建脚本

pull/297/head
ChenX 5 years ago
parent 7b7067b60b
commit e96cac1398

@ -1,5 +1,5 @@
import * as AddAssetHtmlPlugin from "add-asset-html-webpack-plugin";
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
import * as HtmlWebPackPlugin from "html-webpack-plugin";
import * as CleanWebpackPlugin from 'clean-webpack-plugin';
@ -7,7 +7,7 @@ import * as path from 'path';
import * as webpack from 'webpack';
import { outputDir } from "./outputPath";
function getpath(fileName)
function getpath(fileName: string)
{
return path.resolve(__dirname, fileName);
}
@ -143,7 +143,7 @@ const config: webpack.Configuration = {
THREE: "three"
}),
// new HardSourceWebpackPlugin(),
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
// new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
new CleanWebpackPlugin([`./dist/*.main.js`], { root: path.resolve(__dirname, "..") }),
],
node: false

@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"dev": "cross-env TS_NODE_PROJECT=\"./config/tsconfig-for-webpack-config.json\" webpack-dev-server --config ./config/webpack.dev.ts",
"t": "tsc --noEmit -w",
"dev2": "webpack-dev-server --config web-cad-view.config.ts",
"buildview": "webpack --config dll.config.js &&webpack --config web-cad-view.config.ts",
"dll": "webpack --config ./config/webpack.dll.ts",

@ -1,74 +1,8 @@
import * as path from 'path';
import * as http from 'https';
import * as fs from "fs";
import { downLoadFile } from './utils';
//修正d.ts中类型定义出现错误的问题,临时修复,因为d.ts并不能完全快速的合并我们的类型修复PR.
/**
*
*
* @param {string} url
* @param {string} filePath
*/
function downLoadFile(url: string, filePath: string)
{
if (fs.existsSync(filePath))
fs.unlinkSync(filePath);
else
fs.mkdirSync(path.dirname(filePath));
let file = fs.createWriteStream(filePath);
http.get(url, function (response)
{
response.pipe(file);
});
}
/**
* .
*
* @param {*} source
* @param {*} targetFile
*/
export function copyFileSync(source: string, targetFile: string)
{
//if target is a directory a new file with the same name will be created
if (fs.existsSync(targetFile))
{
if (fs.lstatSync(targetFile).isDirectory())
{
targetFile = path.join(targetFile, path.basename(source));
}
}
fs.writeFileSync(targetFile, fs.readFileSync(source));
console.log('targetFile: ', targetFile);
}
function copyFolderRecursiveSync(source, target)
{
let files = [];
//check if folder needs to be created or integrated
let targetFolder = path.join(target, path.basename(source));
if (!fs.existsSync(targetFolder))
{
fs.mkdirSync(targetFolder);
}
//copy
if (fs.lstatSync(source).isDirectory())
{
files = fs.readdirSync(source);
files.forEach(function (file)
{
let curSource = path.join(source, file);
if (fs.lstatSync(curSource).isDirectory())
{
copyFolderRecursiveSync(curSource, targetFolder);
} else
{
copyFileSync(curSource, targetFolder);
}
});
}
}
// copyFolderRecursiveSync("./@types/", "./node_modules/");

@ -1,46 +1,46 @@
import { resolve } from "path";
import { copyFileSync } from "./copy_type";
import { copyFileSync } from "./utils";
const gitlog = require('gitlog');
const options =
{
repo: __dirname
, number: 50
, fields:
['subject', 'authorName', "authorDate"]
, execOptions:
{
maxBuffer: 1000 * 1024
}
repo: __dirname
, number: 50
, fields:
['subject', 'authorName', "authorDate"]
, execOptions:
{
maxBuffer: 1000 * 1024
}
};
let commits = gitlog(options);
let cs = commits.map(c =>
{
return {
subject: c.subject,
auther: c.authorName,
time: c.authorDate
}
return {
subject: c.subject,
auther: c.authorName,
time: c.authorDate
}
});
const fs = require('fs');
fs.writeFile("./dist/log.json", JSON.stringify(cs, null, 2), function (err)
{
if (err)
console.log("日志写入失败", err);
else
console.log("日志写入成功");
if (err)
console.log("日志写入失败", err);
else
console.log("日志写入成功");
});
fs.writeFile("./dist/ver.json", Date.now(), err =>
{
if (err)
console.log("版本写入失败", err);
else
console.log("版本写入成功");
if (err)
console.log("版本写入失败", err);
else
console.log("版本写入成功");
});
copyFileSync(resolve("./utils/log.html"), resolve("./dist/"));

@ -0,0 +1,69 @@
import * as path from 'path';
import * as http from 'https';
import * as fs from "fs";
/**
*
*
* @param {string} url
* @param {string} filePath
*/
export function downLoadFile(url: string, filePath: string)
{
if (fs.existsSync(filePath))
fs.unlinkSync(filePath);
else
fs.mkdirSync(path.dirname(filePath));
let file = fs.createWriteStream(filePath);
http.get(url, function (response)
{
response.pipe(file);
});
}
/**
* .
*
* @param {*} source
* @param {*} targetFile
*/
export function copyFileSync(source: string, targetFile: string)
{
//if target is a directory a new file with the same name will be created
if (fs.existsSync(targetFile))
{
if (fs.lstatSync(targetFile).isDirectory())
{
targetFile = path.join(targetFile, path.basename(source));
}
}
fs.writeFileSync(targetFile, fs.readFileSync(source));
console.log('targetFile: ', targetFile);
}
export function copyFolderRecursiveSync(source, target)
{
let files = [];
//check if folder needs to be created or integrated
let targetFolder = path.join(target, path.basename(source));
if (!fs.existsSync(targetFolder))
{
fs.mkdirSync(targetFolder);
}
//copy
if (fs.lstatSync(source).isDirectory())
{
files = fs.readdirSync(source);
files.forEach(function (file)
{
let curSource = path.join(source, file);
if (fs.lstatSync(curSource).isDirectory())
{
copyFolderRecursiveSync(curSource, targetFolder);
} else
{
copyFileSync(curSource, targetFolder);
}
});
}
}
Loading…
Cancel
Save