Skip to content

Commit 1b61431

Browse files
committed
maint(webpack): Use automatic publicPath determination instead of manually setting it.
1 parent 5c720a4 commit 1b61431

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/public_path.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1+
// BBB: Replaced by: ``output.publicPath = "auto"``
2+
// NOTE: This file will be removed in an upcoming release.
13
// NOTE: Import this file before any other files
24
// Overwrite path to load resources or use default one.
3-
__webpack_public_path__ = window.__patternslib_public_path__; // eslint-disable-line no-undef
4-
// eslint-disable-next-line no-undef
5-
if (!__webpack_public_path__) {
6-
// Get chunks path from current script.
7-
let src = document.currentScript?.src;
8-
if (src) {
9-
src = src.split("/");
10-
src.pop();
11-
__webpack_public_path__ = src.join("/") + "/"; // eslint-disable-line no-undef
12-
}
13-
}
5+
__webpack_public_path__ = // eslint-disable-line no-undef
6+
window.__patternslib_public_path__ || document.currentScript.src + "/../";

webpack/webpack.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ module.exports = (env, argv, config, babel_include = []) => {
3838
chunkFilename: "chunks/[name].[contenthash].min.js",
3939
path: path.resolve(__dirname, "../dist/"),
4040
clean: true, // Clean directory before compiling
41-
// publicPath set in bundle entry points via __webpack_public_path__
42-
// See: https://webpack.js.org/guides/public-path/
43-
// publicPath: "/dist/",
41+
publicPath: "auto",
4442
},
4543
optimization: {},
4644
module: {
@@ -137,8 +135,6 @@ module.exports = (env, argv, config, babel_include = []) => {
137135
"Access-Control-Allow-Origin": "*",
138136
},
139137
};
140-
// Output public path for dev-server
141-
config.output.publicPath = "/dist/";
142138
config.optimization.minimize = false;
143139
config.devtool = "source-map"; // Slowest option. False for no source maps.
144140
config.watchOptions = {

0 commit comments

Comments
 (0)