index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. const { run } = require('runjs')
  11. const chalk = require('chalk')
  12. const config = require('../vue.config.js')
  13. const rawArgv = process.argv.slice(2)
  14. const args = rawArgv.join(' ')
  15. if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
  16. const report = rawArgv.includes('--report')
  17. run(`vue-cli-service build ${args}`)
  18. const port = 9526
  19. const publicPath = config.publicPath
  20. var connect = require('connect')
  21. var serveStatic = require('serve-static')
  22. const app = connect()
  23. app.use(
  24. publicPath,
  25. serveStatic('./dist', {
  26. index: ['index.html', '/']
  27. })
  28. )
  29. app.listen(port, function () {
  30. console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
  31. if (report) {
  32. console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
  33. }
  34. })
  35. } else {
  36. run(`vue-cli-service build ${args}`)
  37. }