Skip to content

Allow custom publicPath to be set alongside baseUrl #2525

Closed
@lsapan

Description

@lsapan

What problem does this feature solve?

Right now any attempt to set publicPath prevents the bundle from compiling with the following error:

Configuration Error: Avoid modifying webpack output.publicPath directly. Use the "baseUrl" option instead.

I understand why that validation is there, as it prevents accidental misconfiguration when users aren't aware of the baseUrl option. That said, there should be some way to bypass this error (or make it a warning).

My bundle gets served from my webapp which is running on a different localhost port (let's say 4000). As such, HMR attempts to load from http://localhost:4000/xxx instead of http://localhost:8080/xxx. I can't put the http://localhost:8080/ in the baseUrl because it simply tacks that onto itself (http://localhost:8080/http://localhost:8080/).

I really just need to override the publicPath for webpack, but keep the baseUrl exactly as it is. I've tried a thousand different things but there doesn't seem to be any other way around this.

What does the proposed API look like?

Either make it a warning, or add some kind of flag that says "hey, I know about baseUrl and I've set it, I just also want to set publicPath too."

Frankly, if both baseUrl and publicPath are set, it can probably be assumed that it's intentional. Maybe only display the error if publicPath is set without baseUrl.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions