-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: publicPath output #5434
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
base: master
Are you sure you want to change the base?
feat: publicPath output #5434
Changes from all commits
ba4acf1
89eb799
2323bf3
2e68d84
a1d7f0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2899,7 +2899,10 @@ class Server { | |
return msg; | ||
}, | ||
}; | ||
const useColor = getColorsOption(this.getCompilerOptions()); | ||
|
||
const compilerOptions = this.getCompilerOptions(); | ||
|
||
const useColor = getColorsOption(compilerOptions); | ||
|
||
const server = /** @type {S} */ (this.server); | ||
|
||
|
@@ -2914,8 +2917,19 @@ class Server { | |
* @param {string} newHostname | ||
* @returns {string} | ||
*/ | ||
const prettyPrintURL = (newHostname) => | ||
url.format({ protocol, hostname: newHostname, port, pathname: "/" }); | ||
const prettyPrintURL = (newHostname) => { | ||
const publicPath = compilerOptions.output.publicPath; | ||
|
||
return url.format({ | ||
protocol, | ||
hostname: newHostname, | ||
port, | ||
pathname: | ||
typeof publicPath === "function" || publicPath === "auto" | ||
? "/" | ||
: publicPath, | ||
}); | ||
}; | ||
|
||
let host; | ||
let localhost; | ||
|
@@ -3062,6 +3076,12 @@ class Server { | |
`Broadcasting "${bonjourProtocol}" with subtype of "webpack" via ZeroConf DNS (Bonjour)`, | ||
); | ||
} | ||
|
||
if (typeof compilerOptions.output.publicPath === "function") { | ||
this.logger.info( | ||
`You probably have a custom public path, please navigate in your browser to the point that you required`, | ||
); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should output this only for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, webpack documentation says that the "auto" value allows you to automatically infer the public path value based on the values in the scripts. Are you sure that we should keep default behavior for "auto" value? https://webpack.js.org/guides/public-path/#automatic-publicpath There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right, but mostly it used only for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I fixed it in this commit. Can you check? |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"use strict"; | ||
|
||
console.log("i am foo!"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
|
||
const { join } = require("path"); | ||
|
||
module.exports = { | ||
mode: "development", | ||
entry: join(__dirname, "foo.js"), | ||
output: { | ||
publicPath: "/foo/", | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"use strict"; | ||
|
||
console.log("i am foo!"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
|
||
const { join } = require("path"); | ||
|
||
module.exports = { | ||
mode: "development", | ||
entry: join(__dirname, "foo.js"), | ||
output: { | ||
publicPath: () => "/any-public-path", | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need respect
function
too... But yeah, we known about it only after compilation, so maybe we can improve our message and write - something likeyou can have custom public path, please navigate in your browsers to the point that you required
(just an example, feel free to improve it)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexander-akait I think adding an info message if public path is
auto
orfunction
would be a good idea, can you check this commit?