From 78b958f86a2b0767339a3bc5e0cd4d43ec4128c0 Mon Sep 17 00:00:00 2001 From: lzh Date: Sat, 21 Jan 2023 02:55:55 +0800 Subject: [PATCH] build/index.js --- supervise-report-ui/build/index.js | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 supervise-report-ui/build/index.js diff --git a/supervise-report-ui/build/index.js b/supervise-report-ui/build/index.js new file mode 100644 index 00000000..0c57de2a --- /dev/null +++ b/supervise-report-ui/build/index.js @@ -0,0 +1,35 @@ +const { run } = require('runjs') +const chalk = require('chalk') +const config = require('../vue.config.js') +const rawArgv = process.argv.slice(2) +const args = rawArgv.join(' ') + +if (process.env.npm_config_preview || rawArgv.includes('--preview')) { + const report = rawArgv.includes('--report') + + run(`vue-cli-service build ${args}`) + + const port = 9526 + const publicPath = config.publicPath + + var connect = require('connect') + var serveStatic = require('serve-static') + const app = connect() + + app.use( + publicPath, + serveStatic('./dist', { + index: ['index.html', '/'] + }) + ) + + app.listen(port, function () { + console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`)) + if (report) { + console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`)) + } + + }) +} else { + run(`vue-cli-service build ${args}`) +}