index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <<<<<<< HEAD
  2. const { run } = require('runjs')
  3. const chalk = require('chalk')
  4. const config = require('../vue.config.js')
  5. const rawArgv = process.argv.slice(2)
  6. const args = rawArgv.join(' ')
  7. if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
  8. const report = rawArgv.includes('--report')
  9. run(`vue-cli-service build ${args}`)
  10. const port = 9526
  11. const publicPath = config.publicPath
  12. var connect = require('connect')
  13. var serveStatic = require('serve-static')
  14. const app = connect()
  15. app.use(
  16. publicPath,
  17. serveStatic('./dist', {
  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. }
  30. =======
  31. const { run } = require('runjs')
  32. const chalk = require('chalk')
  33. const config = require('../vue.config.js')
  34. const rawArgv = process.argv.slice(2)
  35. const args = rawArgv.join(' ')
  36. if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
  37. const report = rawArgv.includes('--report')
  38. run(`vue-cli-service build ${args}`)
  39. const port = 9526
  40. const publicPath = config.publicPath
  41. var connect = require('connect')
  42. var serveStatic = require('serve-static')
  43. const app = connect()
  44. app.use(
  45. publicPath,
  46. serveStatic('./dist', {
  47. index: ['index.html', '/']
  48. })
  49. )
  50. app.listen(port, function () {
  51. console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
  52. if (report) {
  53. console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
  54. }
  55. })
  56. } else {
  57. run(`vue-cli-service build ${args}`)
  58. }
  59. >>>>>>> ec6eeb00ce64eb587a455406167d302dc3e59216