From 57a161ea622802876d3f40ef4875645a5f63aae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A0=E6=B0=B8=E8=BE=89?= Date: Thu, 14 Jan 2021 13:29:37 +0800 Subject: [PATCH] build --- .gitignore | 1 - build/index.js | 35 +++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 build/index.js diff --git a/.gitignore b/.gitignore index 08f8ab1..ed4b821 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,5 @@ selenium-debug.log *.sln *.local admin-web -build diff --git a/build/index.js b/build/index.js new file mode 100644 index 0000000..0c57de2 --- /dev/null +++ b/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}`) +} diff --git a/package.json b/package.json index 2690ca2..8dee01a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "license": "Apache 2.0", "scripts": { "dev": "vue-cli-service serve --open", + "build": "vue-cli-service build", "build:prod": "vue-cli-service build", "build:boot": "vue-cli-service build --mode boot", "build:docker": "vue-cli-service build --mode docker",