feat: 项目结构调整|新增依赖
This commit is contained in:
21
build/scripts/clean.js
Normal file
21
build/scripts/clean.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
function cleanDirectory(dirPath) {
|
||||
const resolvedPath = path.resolve(dirPath)
|
||||
|
||||
const parentDir = path.basename(path.dirname(resolvedPath))
|
||||
if (parentDir !== 'packages') {
|
||||
console.error(`Error: Directory "${resolvedPath}" is not inside a "packages" folder`)
|
||||
return
|
||||
}
|
||||
|
||||
const distPath = path.join(resolvedPath, 'dist')
|
||||
|
||||
if (fs.existsSync(distPath)) {
|
||||
fs.rmSync(distPath, { recursive: true, force: true })
|
||||
console.log(`deleted: ${distPath}`)
|
||||
}
|
||||
}
|
||||
|
||||
cleanDirectory(process.cwd())
|
||||
21
build/scripts/generateProdEntry.js
Normal file
21
build/scripts/generateProdEntry.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
if (!fs.existsSync(path.join(process.cwd(), 'dist/main/build.jsc'))) {
|
||||
throw new Error('字节码文件未找到,请先执行编译')
|
||||
}
|
||||
|
||||
const content = `
|
||||
const {app} = require('electron');
|
||||
require('bytenode');
|
||||
require('./index.jsc);
|
||||
`
|
||||
|
||||
const outputPath = path.join(process.cwd(), 'dist/main/build.js')
|
||||
|
||||
// 确保目录存在
|
||||
fs.mkdirSync(path.dirname(outputPath), { recursive: true })
|
||||
|
||||
// 写入文件
|
||||
fs.writeFileSync(outputPath, content.trim())
|
||||
console.log(`生产环境入口文件已生成: ${outputPath}`)
|
||||
Reference in New Issue
Block a user