代码ts化, 修复编译上传脚本

This commit is contained in:
jie
2024-11-03 22:04:05 +08:00
parent 916150eea2
commit 57c28c29ef
21 changed files with 410 additions and 216 deletions

View File

@@ -4,27 +4,28 @@ import copy from 'rollup-plugin-copy'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from 'rollup-plugin-typescript2' // <== 新增这一行
import { config } from './.secret.js'
let config
console.log(config[process.env.DEST])
// 根据指定的目标获取对应的配置项
if (!process.env.DEST) console.log("未指定目标, 代码将被编译但不会上传")
else if (!(config = require("./.secret.json")[process.env.DEST])) {
else if (config.main == null && config.local == null) {
throw new Error("无效目标,请检查 secret.json 中是否包含对应配置")
}
let runConfig = config[process.env.DEST]
// 根据指定的配置决定是上传还是复制到文件夹
const pluginDeploy = config && config.copyPath ?
const pluginDeploy = runConfig && runConfig.copyPath ?
// 复制到指定路径
copy({
targets: [
{
src: 'dist/main.js',
dest: config.copyPath
dest: runConfig.copyPath
},
{
src: 'dist/main.js.map',
dest: config.copyPath,
dest: runConfig.copyPath,
rename: name => name + '.map.js',
transform: contents => `module.exports = ${contents.toString()};`
}
@@ -33,7 +34,7 @@ const pluginDeploy = config && config.copyPath ?
verbose: true
}) :
// 更新 .map 到 .map.js 并上传
screeps({ config, dryRun: !config })
screeps({ runConfig, dryRun: !config })
export default {
input: 'src/main.ts',