index.js 780 B

12345678910111213141516171819202122232425262728293031
  1. const chalk = require('chalk')
  2. const config = require('../vue.config.js')
  3. const rawArgv = process.argv.slice(2)
  4. const args = rawArgv.join(' ')
  5. if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
  6. const report = rawArgv.includes('--report')
  7. const port = 9526
  8. const publicPath = config.publicPath
  9. var connect = require('connect')
  10. var serveStatic = require('serve-static')
  11. const app = connect()
  12. app.use(
  13. publicPath,
  14. serveStatic('./dist', {
  15. index: ['index.html', '/']
  16. })
  17. )
  18. app.listen(port, function () {
  19. console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
  20. if (report) {
  21. console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
  22. }
  23. })
  24. } else {
  25. }