You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.js 682B

123456789101112131415161718192021222324252627
  1. /**
  2. * @Author : Caven Chen
  3. */
  4. import express from 'express'
  5. import portfinder from 'portfinder'
  6. import fse from 'fs-extra'
  7. import shell from 'shelljs'
  8. import chalk from 'chalk'
  9. export default function start() {
  10. let dist = 'dist'
  11. const server = express()
  12. portfinder.setBasePort(8081)
  13. fse.exists(dist, (exists) => {
  14. if (exists) {
  15. portfinder.getPort((err, port) => {
  16. server.listen(port)
  17. shell.echo(chalk.yellow(`the url is : http://localhost:${port}`))
  18. server.use('/libs/dc-sdk/', express.static(dist))
  19. server.use(express.static('examples'))
  20. })
  21. } else {
  22. shell.echo(chalk.red(`please run build first`))
  23. }
  24. })
  25. }