Skip to content

Commit

Permalink
Migrate from Gulp + Webpack to Vite.
Browse files Browse the repository at this point in the history
  • Loading branch information
pygeek committed Sep 11, 2024
1 parent cec0f15 commit 8af9fd7
Show file tree
Hide file tree
Showing 9 changed files with 860 additions and 2,932 deletions.
493 changes: 0 additions & 493 deletions Gulpfile.js

This file was deleted.

84 changes: 24 additions & 60 deletions src/index.html → index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<!doctype html>
<html lang="{{PAGE_LANGUAGE}}">
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{PAGE_TITLE}}</title>
<title>Play Go at online-go.com!</title>

<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="application-name" content="Online-Go.com"/>
<meta name="keywords" content="{{PAGE_KEYWORDS}}"/>
<meta name="Description" content="{{PAGE_DESCRIPTION}}">
<meta name="keywords" content=""/>
<meta name="Description" content="">

<link rel="manifest" href="/manifest.json">
<link rel="shortcut icon" href="https://cdn.online-go.com/icons/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" sizes="57x57" href="https://cdn.online-go.com/icons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="https://cdn.online-go.com/icons/apple-touch-icon-60x60.png">
Expand All @@ -38,11 +37,10 @@

<meta property="og:site_name" content="online-go.com" />
<meta property="og:type" content="website" />
<meta property="og:title" content="{{OG_TITLE}}" />
<meta property="og:url" content="{{OG_URL}}" />
<meta property="og:image" content="{{OG_IMAGE}}" />
<meta property="og:description" content="{{OG_DESCRIPTION}}" />

<meta property="og:title" content="" />
<meta property="og:url" content="" />
<meta property="og:image" content="" />
<meta property="og:description" content="" />
<style>
@font-face {
font-family: 'Nunito';
Expand Down Expand Up @@ -149,7 +147,7 @@
background-color: #1A1A1A;
}
</style>
{{EXTRA_CONFIG}}
<script>window['websocket_host'] = "https://beta.online-go.com";</script>
</head>
<body>
<script>
Expand All @@ -167,7 +165,7 @@

/* When browsers use Google Translate it breaks React apps like ours because they
* replace text nodes with <font> tags, changing the dom structure and causing
* React to throw errors.
* React to throw errors.
*
* This code is the workaround described by the react team here:
* https://github.com/facebook/react/issues/11538#issuecomment-417504600
Expand Down Expand Up @@ -254,66 +252,33 @@
</div></div>
<div id="main-content"></div>
<div id="toast-container"></div>


<noscript id="deferred-styles">
<link rel="stylesheet" type="text/css" href="{{CDN_SERVICE}}/{{RELEASE}}/ogs.{{VERSION_DOTCSS}}">
</noscript>

<script>
try {
var script = document.createElement('script');
script.id = "ogs_score_estimator_script";
try {
new WebAssembly.Memory({ initial: 0 });
console.log("WASM support detected, score estimator will be fast");
script.src = "/OGSScoreEstimator/OGSScoreEstimator-0.7.0.js";
script.src = "//localhost:8080/OGSScoreEstimator/OGSScoreEstimator-0.7.0.js";
} catch (error) {
console.warn(error);
console.log("No WASM support detected, score estimator falling back to ASM.js mode");
script.src = "/OGSScoreEstimator/OGSScoreEstimator-0.7.0.asm.js";
script.src = "//localhost:8080/OGSScoreEstimator/OGSScoreEstimator-0.7.0.asm.js";
}
document.head.appendChild(script);
} catch (e) {
console.error(e);
}
</script>
<script defer src="https://cdn.online-go.com/lib/jquery/3.1.1/jquery.js"></script>
<script defer src="https://cdn.online-go.com/goban/8.3.50/goban.js"></script>

<script>
var loadDeferredStyles = function() {
var addStylesNode = document.getElementById("deferred-styles");
var replacement = document.createElement("div");
var inner = addStylesNode.textContent
try {
/* Allow the ability to override the css file we load for development / testing purposes */
if (localStorage.getItem('ogs-css')) {
inner = inner.replace("{{CDN_SERVICE}}/{{RELEASE}}/ogs.{{VERSION_DOTCSS}}", "{{CDN_SERVICE}}/" + localStorage.getItem('ogs-css'));
}
} catch (e) {
console.error(e);
}
replacement.innerHTML = inner;
document.body.appendChild(replacement)
addStylesNode.parentElement.removeChild(addStylesNode);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); });
else window.addEventListener('load', loadDeferredStyles);
</script>

<script defer src="https://cdn.online-go.com/lib/es6-shim/0.35.3/es6-shim{{MIN}}.js"></script>
<script defer src="https://cdn.online-go.com/lib/jquery/3.1.1/jquery{{MIN}}.js"></script>
<script defer src="{{GOBAN_JS}}"></script>
<script defer src="{{CDN_SERVICE}}/{{RELEASE}}/vendor.{{VENDOR_HASH_DOTJS}}"></script>


<script type="text/javascript">var supported_languages = {{SUPPORTED_LANGUAGES}};</script>
<script type="text/javascript">var supported_languages = {"be":"Беларуская","ca":"Català","cs":"Čeština","da":"Dansk","de":"Deutsch","en":"English","eo":"Esperanto","es":"Español","eu":"Euskara","et":"Eesti keel","el":"ελληνικά","fi":"Suomi","fr":"Français","he":"עִבְרִית","hu":"Magyar","hr":"Hrvatski","it":"Italiano","ja":"日本語","ko":"한국어","nl":"Nederlands","pl":"Polski","pt":"Português","ro":"Română","ru":"Русский","sr":"Српски","sv":"Svenska","tr":"Türkçe","uk":"Українська","th":"ภาษาไทย","vi":"Tiếng Việt","zh-cn":"简体中文","zh-tw":"繁體中文","debug":"Debug"};</script>
<script type="text/javascript">
var ogs_version='{{VERSION}}';
var ogs_release='{{RELEASE}}';
var ogs_language_version='{{LANGUAGE_VERSION}}';
var cdn_service = '{{CDN_SERVICE}}';
var ogs_version='';
var ogs_release='';
var ogs_language_version='';
var cdn_service = '//localhost:8080/';

/* Detect preferred language */

Expand Down Expand Up @@ -403,22 +368,22 @@
window['ogs_current_language'] = ogs_current_language || 'en';

/* Load our translations */
var language_path = "{{CDN_SERVICE}}/{{RELEASE}}/locale/" + ogs_current_language + ".{{LANGUAGE_VERSION_DOTJS}}";
var language_path = "//localhost:8080///locale/" + ogs_current_language + ".js";
language_path = language_path.replace('///', '/'); /* in dev mode, we don't use the cdn or release vars */
document.write('<script defer src="' + language_path + '"><' + '/script>');

/* Load OGS. We can override what script is loaded by setting the
* 'ogs-script' entry in localStorage (useful for testing versions before they're
* released to everyone) */
var ogs_script_path = "{{CDN_SERVICE}}/{{RELEASE}}/ogs.{{OGS_VERSION_HASH_DOTJS}}";
var ogs_script_path = "//localhost:8080///ogs.js";
try {
if (localStorage.getItem('ogs-script')) {
ogs_script_path = "{{CDN_SERVICE}}/" + localStorage.getItem('ogs-script');
ogs_script_path = "//localhost:8080//" + localStorage.getItem('ogs-script');
}
} catch (e) {
console.error(e);
}
document.write('<script defer src="' + ogs_script_path + '"><'+'/script>');
//document.write('<script defer src="' + ogs_script_path + '"><'+'/script>');

</script>

Expand Down Expand Up @@ -469,8 +434,7 @@
localStorage.removeItem('ogs-script');
}
</script>

{{LIVE_RELOAD}}
<script type="module" src="src/main.tsx"></script>
</body>

</html>
22 changes: 6 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
"npm": ">=8.5.0"
},
"scripts": {
"dev": "supervisor -w Gulpfile.js,webpack.config.js,tsconfig.json supervisor -w Gulpfile.js -x gulp --",
"dev": "npx tsx server.ts",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
"prettier:check": "prettier --check \"src/**/*.{ts,tsx}\"",
"webpack": "webpack",
"webpack-watch": "webpack --watch --progress --color",
"lint": "eslint src/",
"lintold": "eslint src/ --ext=.ts,.tsx -c .eslintrc.js",
"lint:fix": "eslint --fix src/ --ext=.ts,.tsx -c .eslintrc.js",
"test": "jest",
"fresh-test": "clear && jest",
"gulp": "gulp",
"spellcheck": "cspell \"src/**/*.{ts,tsx}\"",
"minify-index": "gulp minify-index --silent",
"analyze": "webpack --mode production --profile --optimization-minimize --devtool=source-map",
"yarn": "yarn"
},
Expand Down Expand Up @@ -49,6 +45,7 @@
"css-what": "^6.1.0",
"cssnano": "^6.0.1",
"deepl-node": "^1.10.1",
"esbuild-plugin-react-virtualized": "^1.0.4",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -62,14 +59,6 @@
"fork-ts-checker-webpack-plugin": "^9.0.0",
"globals": "^15.8.0",
"goban": "=8.3.50",
"gulp": "^5.0.0",
"gulp-clean-css": "^4.3.0",
"gulp-eslint-new": "^2.2.0",
"gulp-livereload": "^4.0.2",
"gulp-postcss": "^9.0.0",
"gulp-rename": "^2.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-stylus": "^2.7.0",
"html-minifier": "4.0.0",
"husky": "^8.0.1",
"jest": "^29.7.0",
Expand All @@ -89,9 +78,8 @@
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.1",
"typescript": "=5.5.4",
"webpack": "^5.94.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
"vite": "^5.4.3",
"vite-express": "^0.19.0",
"xgettext-js": "^3.0.0",
"yarn": "^1.22.19"
},
Expand All @@ -115,9 +103,11 @@
"@types/react-dom": "^18.0.11",
"@types/react-virtualized": "^9.21.21",
"@types/sanitize-html": "^1.22.0",
"@vitejs/plugin-react": "^4.3.1",
"array-move": "^2.2.1",
"d3": "^7.6.1",
"date-fns": "^3.6.0",
"eslint-plugin-react-refresh": "^0.4.11",
"eventemitter3": "^5.0.0",
"howler": "^2.2.1",
"jquery": "^3.6.0",
Expand Down
Loading

0 comments on commit 8af9fd7

Please sign in to comment.