index.js 906 B

12345678910111213141516171819202122232425262728293031323334353637
  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. if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
  7. const report = rawArgv.includes('--report')
  8. run(`vue-cli-service build ${args}`)
  9. const port = 9526
  10. const publicPath = config.publicPath
  11. const base
  12. var connect = require('connect')
  13. var serveStatic = require('serve-static')
  14. const app = connect()
  15. app.use(
  16. publicPath,
  17. serveStatic('./front', {
  18. index: ['index.html', '/']
  19. })
  20. )
  21. app.listen(port, function () {
  22. console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
  23. if (report) {
  24. console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
  25. }
  26. })
  27. } else {
  28. run(`vue-cli-service build ${args}`)
  29. }