Skip to content
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

Fix public path once again #1152

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export const Header: React.FC<Props> = ({ setOverlayBoxState, inert }) => {
};

const Logo: React.FC = () => {
const path = (filename: string) => DEFINES.publicPath
+ (DEFINES.publicPath.endsWith("/") ? "" : "/")
+ filename;
const path = (filename: string) => DEFINES.publicPath + filename;

return (
<picture css={{
Expand Down
8 changes: 1 addition & 7 deletions src/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,6 @@ export class SettingsManager {
* appropriate message on console.
*/
static async loadContextSettings() {
// Try to retrieve the context settings.
let basepath = DEFINES.publicPath;
if (!basepath.endsWith("/")) {
basepath += "/";
}

// Construct path to settings file. If the `SETTINGS_PATH` is given and
// starts with '/', it is interpreted as absolute path from the server
// root.
Expand All @@ -254,7 +248,7 @@ export class SettingsManager {
}
}

const base = settingsPath.startsWith("/") ? "" : basepath;
const base = settingsPath.startsWith("/") ? "" : DEFINES.publicPath;
const url = `${window.location.origin}${base}${settingsPath}`;
let response: Response;
try {
Expand Down
9 changes: 7 additions & 2 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";

const OUT_PATH = path.join(__dirname, "build");

let publicPath = process.env.PUBLIC_PATH ?? "/";
if (!publicPath.endsWith("/")) {
publicPath += "/";
}

const config: CallableOption = (_env, argv) => ({
entry: "./src/index.tsx",
output: {
filename: "[name].bundle.js",
path: OUT_PATH,
publicPath: `${process.env.PUBLIC_PATH ?? ""}/`,
publicPath,
},
devtool: argv.mode === "development" ? "eval-cheap-module-source-map" : "source-map",
resolve: {
Expand Down Expand Up @@ -55,7 +60,7 @@ const config: CallableOption = (_env, argv) => ({
// Passing compile time values into the code
new DefinePlugin({
DEFINE_SETTINGS_PATH: JSON.stringify(process.env.SETTINGS_PATH),
DEFINE_PUBLIC_PATH: JSON.stringify(process.env.PUBLIC_PATH),
DEFINE_PUBLIC_PATH: JSON.stringify(publicPath),
DEFINE_SHOW_LEGAL_NOTICES: JSON.stringify(process.env.INCLUDE_LEGAL_NOTICES),
DEFINE_BUILD_DATE: JSON.stringify(process.env.BUILD_DATE),
DEFINE_COMMIT_SHA: JSON.stringify(process.env.COMMIT_SHA),
Expand Down