Skip to content

Commit

Permalink
fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterbene committed Jun 14, 2023
1 parent 1b28de1 commit 2d48b77
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 42 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const NODE_ENV = process.env.NODE_ENV;

module.exports = {
extends: ["react-app"],
// ISSUE: https://github.com/facebook/create-react-app/issues/12070 --> will be fixed with next cra version
parserOptions: {
babelOptions: { presets: [["babel-preset-react-app", false]] },
},
};
19 changes: 15 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"i18n-ally.localesPaths": [
"src/translations/locales"
]
}
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"i18n-ally.localesPaths": [
"src/translations/locales"
],
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features",
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
},
}
35 changes: 19 additions & 16 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
const {
override,
addWebpackModuleRule,
} = require("customize-cra");
const { override, addWebpackModuleRule } = require("customize-cra");

const setGlobalObject = value => config => {
const setGlobalObject = (value) => (config) => {
// mutate config as you want
config.output.globalObject = value;

// return config so the next function in the pipeline receives it as argument
return config
}
return config;
};

const overrideStats = (value) => (config) => {
config.stats = value;
return config;
};

module.exports = (config, env) => {
return override(
setGlobalObject('(self || this)'),
setGlobalObject("(self || this)"),
/*overrideStats({
children: true
}),*/ // enable if you weant to see more detailed stats for debug
addWebpackModuleRule({
test: /\.html$/,
use: [
{loader: 'html-loader', options: { esModule: true }}
]
use: [{ loader: "html-loader", options: { esModule: true } }],
}),
addWebpackModuleRule({
test: /(\.worker|mapbox-gl-csp-worker).js$/,
use: [
{
loader: 'worker-loader',
loader: "worker-loader",
options: {
filename: "[name].[contenthash].worker.js"
}
filename: "[name].[contenthash].worker.js",
},
},
]
],
})
)(config, env);
}
};
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"wikimedia-commons-file-path": "^2.1.1"
},
"engines": {
"node": ">=16.0.0 <17.0.0"
"node": ">=18.0.0 <19.0.0"
},
"scripts": {
"start": "react-app-rewired start",
Expand All @@ -43,9 +43,6 @@
"manage:translations": "formatjs extract 'src/components/**/*.js*' --out-file src/translations/extractedMessages.json --format simple",
"check:boundaries": "node ./boundary-checker.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
41 changes: 23 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import * as serviceWorker from './workers/serviceWorkerRegister';
import * as Sentry from '@sentry/browser';
import { SENTRY_DSN } from './config';
import confirm from './lib/confirm';
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import * as serviceWorker from "./workers/serviceWorkerRegister";
import * as Sentry from "@sentry/browser";
import { SENTRY_DSN } from "./config";
import confirm from "./lib/confirm";

// force HTTPS
const { location } = window;
if (!serviceWorker.isLocalhost && location.protocol !== 'https:') {
location.replace(`https:${location.href.substring(location.protocol.length)}`);
if (!serviceWorker.isLocalhost && location.protocol !== "https:") {
location.replace(
`https:${location.href.substring(location.protocol.length)}`
);
}

// add sentry error tracking
Sentry.init({dsn: SENTRY_DSN});
Sentry.init({ dsn: SENTRY_DSN });

const container = document.getElementById('root');
const container = document.getElementById("root");
const root = createRoot(container);
root.render(<App />);

Expand All @@ -24,13 +26,16 @@ root.render(<App />);
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.register({
onUpdate: async () => {
if( await confirm({
title: 'Neue WikiDaheim-Version verfügbar',
content: 'Möchtest du die Seite neu laden, um die aktuellste Version zu verwenden?',
cancelTitle: 'Jetzt nicht',
confirmTitle: 'Ja, Seite neu Laden'
})) {
if (
await confirm({
title: "Neue WikiDaheim-Version verfügbar",
content:
"Möchtest du die Seite neu laden, um die aktuellste Version zu verwenden?",
cancelTitle: "Jetzt nicht",
confirmTitle: "Ja, Seite neu Laden",
})
) {
window.location.reload();
}
}
},
});

0 comments on commit 2d48b77

Please sign in to comment.