春风项目四线(合箱线、总装线)
cl
2024-01-16 e2f15526d72f9c2cc9ffc609d85d10be6421c158
提交 | 用户 | 时间
fd2207 1 const { run } = require('runjs')
2 const chalk = require('chalk')
3 const config = require('../vue.config.js')
4 const rawArgv = process.argv.slice(2)
5 const args = rawArgv.join(' ')
6
7 if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
8   const report = rawArgv.includes('--report')
9
10   run(`vue-cli-service build ${args}`)
11
12   const port = 9526
13   const publicPath = config.publicPath
14
15   var connect = require('connect')
16   var serveStatic = require('serve-static')
17   const app = connect()
18
19   app.use(
20     publicPath,
21     serveStatic('./dist', {
22       index: ['index.html', '/']
23     })
24   )
25
26   app.listen(port, function () {
27     console.log(chalk.green(`> Preview at  http://localhost:${port}${publicPath}`))
28     if (report) {
29       console.log(chalk.green(`> Report at  http://localhost:${port}${publicPath}report.html`))
30     }
31
32   })
33 } else {
34   run(`vue-cli-service build ${args}`)
35 }