Skip to content

Customize or disable serve console message #2115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chasegiunta opened this issue Aug 8, 2018 · 9 comments
Closed

Customize or disable serve console message #2115

chasegiunta opened this issue Aug 8, 2018 · 9 comments

Comments

@chasegiunta
Copy link

What problem does this feature solve?

In non-SPA setups, the server may be operating on localhost:8080 and serving assets from there, but the site is being viewed on a separate domain my-php-site.test. In order for HMR to work correctly we enabled things like headers: { 'Access-Control-Allow-Origin': '*' } & set our baseUrl as

baseUrl: process.env.NODE_ENV === 'production'
  ? '/'
  : 'http://localhost:8080/',

This works great, except the dev will receive this message running serve:

App running at:
  - Local:   http://localhost:8080/http://localhost:8080/ 
  - Network: http://10.0.1.12:8080/http://localhost:8080/

What does the proposed API look like?

Potentially, if a serveMessage is provided, it will override any console messages.

@yyx990803
Copy link
Member

That's the wrong way to enable HMR. Use devServer.public for that purpose.

@chasegiunta
Copy link
Author

@yyx990803 if you set devServer.public to localhost:8080 it's ignored. Requests fallback to window.location

@yyx990803
Copy link
Member

You should set devServer.public to my-php-site.test to make HMR work.

@chasegiunta
Copy link
Author

chasegiunta commented Aug 8, 2018

@yyx990803 in the older vue-webpack template, we were able to set devServer.publicPath to http://localhost:8080 to achieve what we needed since it supports full URLs, but that option is being overridden to options.baseUrl anyway (which may be a valid requirement), hence the reasoning for the FR.

EDIT: ah, just saw your response. will try, but it looks to be already requesting http://my-php-site.test/6a0ce03e6867e8fa287b.hot-update.json anyway

@chasegiunta
Copy link
Author

@yyx990803 Yeah, that's not going to work. Apologies if I'm not communicating thoroughly, but the devServer isn't running under my my-php-site.test. The site is being served from my-php-site.test and during development, loading localhost:8080/app.js from the devServer.

@yyx990803
Copy link
Member

@chasegiunta I see. That's weird, because in this case it should just work without any configuration. If it's really not, I will need a reproduction. Or I'd suggest taking a look at https://github.com/yyx990803/laravel-vue-cli-3

@chasegiunta
Copy link
Author

chasegiunta commented Aug 8, 2018

Hmmm. That approach is going back to working from the dev server and proxying your site. I think we've had issues with this in the past, and I've seen many folks from the Laravel community & mix users who have the same dev environment as I (work in my-php-app.test, but load your app.js from the dev server localhost:8080) as shown in Mix's docs. Not saying it wouldn't work, and I can't quite recall why many people didn't do it this way. Will investigate further.

@csicky
Copy link

csicky commented Feb 11, 2019

The title of this issue is about how to change the console message. The discussion is about something else. I understand that it was an AB problem and the discussion solves the real problem, but for people arriving here from Google there is no information about how to change the console messages from npm run serve.
I would like to be able to see only if there is a problem, if it's green, yellow or red. I don't want to give so much screen to the console, but in order to see what I want I have to see also the entire message which I know already:

 DONE  Compiled successfully in 24499ms      
  App running at:
  - Local:   http://localhost:8080/
  - Network: http://192.168.100.10:8080/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

I need a way to have the console say only:

 DONE  Compiled successfully in 24499ms      

@phistep
Copy link

phistep commented Mar 16, 2021

I'm building an app against an API, which I mock locally, but sometimes run tests from my local setup against the public (staging) API endpoint. I can configure the endpoint URL using variables in .env files. So I have one to run locally against the mock, one to run locally against the public staging API and one to run on the staging server against the public staging API etc. I would like to see in the output not only the local and network URL, but also which API URL is configured, so I won't get confused which one I am targeting right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants