|
@@ -4,21 +4,28 @@ const fs = require('fs');
|
|
|
// 获取当前命令行上下文路径
|
|
|
const currentDirectory = process.cwd();
|
|
|
|
|
|
+console.log(`----------------------------`)
|
|
|
+console.log(`正在处理编译打包前的准备...`)
|
|
|
+
|
|
|
//删除上次打包相关的文件
|
|
|
+console.log(`正在删除上次打包相关的文件...`)
|
|
|
const distZipPath = path.join(currentDirectory, '/zip/archives.zip');
|
|
|
if(fs.existsSync(distZipPath)) {
|
|
|
fs.unlinkSync(distZipPath);
|
|
|
}
|
|
|
|
|
|
// 获取配置文件
|
|
|
+console.log(`获取当前的配置文件...`)
|
|
|
const indexJsonPath = path.join(currentDirectory, 'src/config/index.json');
|
|
|
const indexJsonContent = fs.readFileSync(indexJsonPath, 'utf8');
|
|
|
|
|
|
//创建缓存文件
|
|
|
+console.log(`创建配置缓存文件...`)
|
|
|
const cacheJsonPath = path.join(currentDirectory, 'scripts/cache.json');
|
|
|
fs.writeFileSync(cacheJsonPath, indexJsonContent, 'utf8');
|
|
|
|
|
|
//修改配置文件
|
|
|
+console.log(`修改配置文件为生产环境的配置...`)
|
|
|
const indexJson = JSON.parse(indexJsonContent);
|
|
|
indexJson.version = dateFormat(new Date()); //版本号
|
|
|
indexJson.target = "http://127.0.0.1:8090"; //接口地址
|
|
@@ -26,8 +33,12 @@ indexJson.smsPhone = ""; //短信接口手机号
|
|
|
indexJson.vite = {}; //vite配置
|
|
|
|
|
|
//更新配置文件
|
|
|
+console.log(`更新配置文件...`)
|
|
|
fs.writeFileSync(indexJsonPath, JSON.stringify(indexJson, null, 2));
|
|
|
|
|
|
+console.log(`----------------------------`)
|
|
|
+console.log(`开始编译打包项目...`)
|
|
|
+
|
|
|
//时间格式化
|
|
|
function dateFormat(date) {
|
|
|
let format = 'yyyyMMddhhmmss';
|