Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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