You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
// @ts-nocheck
|
|
import { spawn } from "child_process"
|
|
import { join } from "path"
|
|
import { rollup, OutputOptions } from "rollup"
|
|
import * as chalk from "chalk"
|
|
import options from "../rollup.config"
|
|
|
|
export function tscCheck() {
|
|
return new Promise((resolve, reject) => {
|
|
let tscProcess = spawn("node", [join(__dirname, "../../node_modules/typescript/bin/tsc")], {
|
|
stdio: "pipe",
|
|
// env: Object.assign(process.env, { NODE_ENV: argv.env }),
|
|
})
|
|
if (tscProcess) {
|
|
tscProcess.stdout.on("end", data => {
|
|
console.log(`[tsc check end]`)
|
|
resolve(tscProcess)
|
|
})
|
|
tscProcess.stderr.on("data", data => {
|
|
console.error(`[tsc check err]: ${data}`)
|
|
reject()
|
|
})
|
|
} else {
|
|
reject()
|
|
}
|
|
})
|
|
}
|
|
export async function buildMain() {
|
|
try {
|
|
const opts = options(process.env.NODE_ENV)
|
|
const build = await rollup(opts)
|
|
build.write(opts.output as OutputOptions)
|
|
} catch (error) {
|
|
console.log(`\n${"[build-main.ts]"} ${chalk.red("构建报错")}\n`, error, "\n")
|
|
}
|
|
}
|
|
|