2018-11-28 10:11:18 +00:00
|
|
|
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')) {
|
|
|
|
run(`vue-cli-service build ${args}`)
|
|
|
|
|
|
|
|
const port = 9526
|
2019-03-08 09:57:14 +00:00
|
|
|
const publicPath = config.publicPath
|
2018-11-28 10:11:18 +00:00
|
|
|
|
|
|
|
var connect = require('connect')
|
|
|
|
var serveStatic = require('serve-static')
|
|
|
|
const app = connect()
|
|
|
|
|
|
|
|
app.use(
|
2019-03-08 09:57:14 +00:00
|
|
|
publicPath,
|
2018-11-28 10:11:18 +00:00
|
|
|
serveStatic('./dist', {
|
|
|
|
index: ['index.html', '/']
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
app.listen(port, function() {
|
|
|
|
console.log(
|
2019-03-08 09:57:14 +00:00
|
|
|
chalk.green(`> Listening at http://localhost:${port}${publicPath}`)
|
2018-11-28 10:11:18 +00:00
|
|
|
)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
run(`vue-cli-service build ${args}`)
|
|
|
|
}
|