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.

61 lines
1.4 KiB

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