status.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. const colors = require('./colors');
  3. const runOpen = require('./runOpen');
  4. // TODO: don't emit logs when webpack-dev-server is used via Node.js API
  5. function status(uri, options, log, useColor) {
  6. const contentBase = Array.isArray(options.contentBase)
  7. ? options.contentBase.join(', ')
  8. : options.contentBase;
  9. if (options.socket) {
  10. log.info(`Listening to socket at ${colors.info(useColor, options.socket)}`);
  11. } else {
  12. log.info(`Project is running at ${colors.info(useColor, uri)}`);
  13. }
  14. log.info(
  15. `webpack output is served from ${colors.info(useColor, options.publicPath)}`
  16. );
  17. if (contentBase) {
  18. log.info(
  19. `Content not from webpack is served from ${colors.info(
  20. useColor,
  21. contentBase
  22. )}`
  23. );
  24. }
  25. if (options.historyApiFallback) {
  26. log.info(
  27. `404s will fallback to ${colors.info(
  28. useColor,
  29. options.historyApiFallback.index || '/index.html'
  30. )}`
  31. );
  32. }
  33. if (options.bonjour) {
  34. log.info(
  35. 'Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)'
  36. );
  37. }
  38. if (options.open) {
  39. runOpen(uri, options, log);
  40. }
  41. }
  42. module.exports = status;