Commit e54483f6 authored by Yoelis Acourt's avatar Yoelis Acourt

wip: serve frontend with parcel on a separate port for dev

parent 6b2fdd33
Pipeline #6985 passed with stages
in 17 minutes and 49 seconds
{
sourceMaps: "inline",
presets: [
["@babel/preset-env", {"useBuiltIns": "usage", "corejs": 3}],
"@babel/preset-react"
],
plugins: []
}
const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
app.use("/api", createProxyMiddleware({
target: 'http://localhost:8008/api',
}))
app.use(
"/ws",
createProxyMiddleware({
target: "ws://127.0.0.1:8008",
ws: true,
changeOrigin: true,
logger: console,
on: {
proxyRes: (proxyRes, req, res) => {
console.log(`[Proxy Response] ${req.method} ${req.url} <- ${proxyRes.statusCode}`);
},
proxyReqWs: (proxyReq, req, socket, options, head) => {
console.log(`WS RESPONSE, ${req.method} ${req.url} <- ${proxyReq.getHeader("host")}`);
proxyReq.setHeader("origin", "http://localhost:8008");
},
proxyReq: (proxyReq, req, res) => {
console.log(`[Proxy Req] ${req.method} ${req.url} <- ${proxyReq.getHeader("host")}`);
proxyReq.setHeader("origin", "http://localhost:8008");
},
error: (err, req, res) => {
console.error(`[Proxy Error] ${req.method} ${req.url} - ${err.message}`);
res.writeHead(500, { "Content-Type": "text/plain" });
res.end("Proxy error occurred.");
}
}
})
);
};
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>CNRS GarganText</title>
<link rel="stylesheet" href="../icons/forkawesome.css">
<!-- <link href="styles/bootstrap.min.css" rel="stylesheet"> -->
<link id="bootstrap-css" href="../styles/bootstrap-default.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../styles/highlightjs-solarized-light.css" />
<style> * {margin: 0; padding: 0; list-style: none;} </style>
</head>
<body>
<div id="app"></div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.6/dist/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> <div id="portal"></div>
<!-- <script type="module" src="../js/jquery.js"></script> -->
<!-- <script type="module" src="../js/bootstrap@4.6.2/bootstrap.bundle.min.js"></script> -->
<script type="module" src="../bundle.min.js"></script>
</body>
</html>
......@@ -12,7 +12,7 @@
<body>
<div id="app"></div>
<div id="portal"></div>
<script src="js/jquery@3.5.1/jquery.slim.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/bootstrap@4.6.2/bootstrap.bundle.min.js"></script>
<script src="bundle.min.js"></script>
</body>
......
This diff is collapsed.
This diff is collapsed.
......@@ -26,6 +26,8 @@
#spago-unstable
esbuild
nodejs
watchexec
pscid
nodePackages.npm
];
......
......@@ -36,6 +36,7 @@
"graphql": "~15.6.1",
"graphql-ws": "~5.5.0",
"highlightjs": "~9.16.2",
"http-proxy-middleware": "^3.0.3",
"immer": "~9.0.5",
"isomorphic-unfetch": "~3.1.0",
"markdown-it": "~13.0.1",
......@@ -59,6 +60,7 @@
"@getgauge/cli": "~1.4.0",
"esbuild": "~0.21.1",
"parcel": "~2.8.2",
"process": "^0.11.10",
"react-testing-library": "~8.0.1",
"sass": "~1.77.0",
"serve": "~14.2.3",
......@@ -3806,6 +3808,14 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/http-proxy": {
"version": "1.17.15",
"resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.15.tgz",
"integrity": "sha512-25g5atgiVNTIv0LBDTg1H74Hvayx0ajtJPLLcYE3whFv75J0pWNtOBzaXJQgDTmrX1bx5U9YC2w/n65BN1HwRQ==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/invariant": {
"version": "2.2.37",
"license": "MIT"
......@@ -3833,7 +3843,6 @@
},
"node_modules/@types/node": {
"version": "20.12.7",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~5.26.4"
......@@ -4580,7 +4589,6 @@
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"dependencies": {
"fill-range": "^7.1.1"
},
......@@ -5907,10 +5915,11 @@
"integrity": "sha512-8X8SS+PEkaBBi1tUVZVT4xFImHI9iQ7uSazoHMjoSJ603hY4ZrffwDg0MExbGnYH+7J3QY2ElnCCJEgaIBZ8bA=="
},
"node_modules/debug": {
"version": "4.3.4",
"license": "MIT",
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
"dependencies": {
"ms": "2.1.2"
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
......@@ -6452,6 +6461,11 @@
"node": ">= 0.6"
}
},
"node_modules/eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
},
"node_modules/events": {
"version": "3.3.0",
"license": "MIT",
......@@ -6645,7 +6659,6 @@
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"dependencies": {
"to-regex-range": "^5.0.1"
},
......@@ -6668,6 +6681,25 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/fresh": {
"version": "0.5.2",
"dev": true,
......@@ -7318,6 +7350,35 @@
"dev": true,
"license": "ISC"
},
"node_modules/http-proxy": {
"version": "1.18.1",
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
"integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
"dependencies": {
"eventemitter3": "^4.0.0",
"follow-redirects": "^1.0.0",
"requires-port": "^1.0.0"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/http-proxy-middleware": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-3.0.3.tgz",
"integrity": "sha512-usY0HG5nyDUwtqpiZdETNbmKtw3QQ1jwYFZ9wi5iHzX2BcILwQKtYDJPo7XHTsu5Z0B2Hj3W9NNnbd+AjFWjqg==",
"dependencies": {
"@types/http-proxy": "^1.17.15",
"debug": "^4.3.6",
"http-proxy": "^1.18.1",
"is-glob": "^4.0.3",
"is-plain-object": "^5.0.0",
"micromatch": "^4.0.8"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/http2-wrapper": {
"version": "1.0.3",
"dev": true,
......@@ -7524,7 +7585,6 @@
},
"node_modules/is-extglob": {
"version": "2.1.1",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
......@@ -7540,7 +7600,6 @@
},
"node_modules/is-glob": {
"version": "4.0.3",
"dev": true,
"license": "MIT",
"dependencies": {
"is-extglob": "^2.1.1"
......@@ -7558,7 +7617,6 @@
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"engines": {
"node": ">=0.12.0"
}
......@@ -7574,6 +7632,14 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-plain-object": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-port-reachable": {
"version": "3.1.0",
"dev": true,
......@@ -8956,10 +9022,9 @@
"license": "MIT"
},
"node_modules/micromatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz",
"integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==",
"dev": true,
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dependencies": {
"braces": "^3.0.3",
"picomatch": "^2.3.1"
......@@ -9474,8 +9539,9 @@
}
},
"node_modules/ms": {
"version": "2.1.2",
"license": "MIT"
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/msgpackr": {
"version": "1.10.1",
......@@ -9865,8 +9931,9 @@
},
"node_modules/parcel": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/parcel/-/parcel-2.8.3.tgz",
"integrity": "sha512-5rMBpbNE72g6jZvkdR5gS2nyhwIXaJy8i65osOqs/+5b7zgf3eMKgjSsDrv6bhz3gzifsba6MBJiZdBckl+vnA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@parcel/config-default": "2.8.3",
"@parcel/core": "2.8.3",
......@@ -10046,7 +10113,6 @@
},
"node_modules/picomatch": {
"version": "2.3.1",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
......@@ -10606,6 +10672,15 @@
"node": ">=8"
}
},
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
"dev": true,
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/process-nextick-args": {
"version": "2.0.1",
"dev": true,
......@@ -11365,7 +11440,6 @@
},
"node_modules/requires-port": {
"version": "1.0.0",
"dev": true,
"license": "MIT"
},
"node_modules/resolve": {
......@@ -12355,7 +12429,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"dependencies": {
"is-number": "^7.0.0"
},
......@@ -12499,7 +12572,6 @@
},
"node_modules/undici-types": {
"version": "5.26.5",
"dev": true,
"license": "MIT"
},
"node_modules/unfetch": {
......
......@@ -2,10 +2,11 @@
"name": "Gargantext",
"version": "0.0.7.3.7",
"scripts": {
"build": "spago build",
"bundle": "spago bundle --module Main --outfile dist/bundle.min.js --minify --source-maps",
"css": "$npm_execpath run css-themes",
"css-themes": "$npm_execpath run css-default-theme && $npm_execpath run css-dark-theme && $npm_execpath run css-darkster-theme && $npm_execpath run css-greyson-theme && $npm_execpath run css-herbie-theme && $npm_execpath run css-monotony-theme",
"build": "spago bundle --module Main --outfile dist/bundle.min.js --minify --source-maps",
"watch": "pscid -O dist/bundle.min.js -I src",
"bundle-dev": "spago bundle --module Main --outfile dist/index.js",
"css": "$npm_execpath css-themes",
"css-themes": "$npm_execpath css-default-theme && $npm_execpath css-dark-theme && $npm_execpath css-darkster-theme && $npm_execpath css-greyson-theme && $npm_execpath css-herbie-theme && $npm_execpath css-monotony-theme",
"css-default-theme": "sass src/sass/themes/default.scss:dist/styles/bootstrap-default.css",
"css-dark-theme": "cp node_modules/bootstrap-dark/src/bootstrap-dark.css dist/styles/bootstrap-dark.css",
"css-darkster-theme": "sass src/sass/themes/darkster.scss:dist/styles/bootstrap-darkster.css",
......@@ -16,7 +17,12 @@
"repl": "spago repl",
"server": "serve -l 8008 dist",
"server-ssl": "ssl-serve --ssl dist",
"test": "spago test"
"test": "spago test",
"serve": "npx parcel serve --no-hmr --dist-dir ./dist/dev/bundle ./dist/dev/index.html"
},
"alias": {
"$": "jquery",
"jQuery": "jquery"
},
"dependencies": {
"@fontsource/crete-round": "~5.0.12",
......@@ -47,6 +53,7 @@
"graphql": "~15.6.1",
"graphql-ws": "~5.5.0",
"highlightjs": "~9.16.2",
"http-proxy-middleware": "^3.0.3",
"immer": "~9.0.5",
"isomorphic-unfetch": "~3.1.0",
"markdown-it": "~13.0.1",
......@@ -70,6 +77,7 @@
"@getgauge/cli": "~1.4.0",
"esbuild": "~0.21.1",
"parcel": "~2.8.2",
"process": "^0.11.10",
"react-testing-library": "~8.0.1",
"sass": "~1.77.0",
"serve": "~14.2.3",
......
......@@ -15,25 +15,26 @@ import Gargantext.Utils (href)
defaultBackends :: NonEmpty Array Backend
defaultBackends = backend' "Demo" "Public Show room" "https://demo.gargantext.org"
:| [ backend' "Education" "Training/Formation" "https://formation.gargantext.org"
, backend' "Academia" "Academia" "https://academia.sub.gargantext.org"
, backend' "Organization" "CNRS" "https://cnrs.gargantext.org"
, backend' "Organization" "Mines Telecom Institute" "https://imt.sub.gargantext.org"
, backend' "Organization" "Hello Word Company" "https://helloword.gargantext.org"
, backend' "Community" "Complex Systems" "https://complexsystems.gargantext.org"
, backend' "Networking" "European Projects" "https://europa.gargantext.org"
, backend' "Community" "Earth" "https://earth.sub.gargantext.org"
, backend' "Community" "Health" "https://health.sub.gargantext.org"
, backend' "Community" "MSH" "https://msh.sub.gargantext.org"
, backend' "Development" "Main SandBox" "https://dev.sub.gargantext.org"
, backend' "Private" "Offline Bunker" "http://localhost:8008"
]
defaultBackends = backend' "Demo" "Public Show room" "https://demo.gargantext.org"
:|
[ backend' "Education" "Training/Formation" "https://formation.gargantext.org"
, backend' "Academia" "Academia" "https://academia.sub.gargantext.org"
, backend' "Organization" "CNRS" "https://cnrs.gargantext.org"
, backend' "Organization" "Mines Telecom Institute" "https://imt.sub.gargantext.org"
, backend' "Organization" "Hello Word Company" "https://helloword.gargantext.org"
, backend' "Community" "Complex Systems" "https://complexsystems.gargantext.org"
, backend' "Networking" "European Projects" "https://europa.gargantext.org"
, backend' "Community" "Earth" "https://earth.sub.gargantext.org"
, backend' "Community" "Health" "https://health.sub.gargantext.org"
, backend' "Community" "MSH" "https://msh.sub.gargantext.org"
, backend' "Development" "Main SandBox" "https://dev.sub.gargantext.org"
, backend' "Private" "Offline Bunker" "http://localhost:8008"
, backend' "Parcel" "Offline Bunker" "http://localhost:1234"
]
where
backend' t n u = backend t n V10 "/api/" u
backend' t n u = backend t n V10 "/api/" u
matchCurrentLocation :: Effect (Maybe Backend)
matchCurrentLocation = do
......@@ -84,4 +85,3 @@ defaultFrontends = Frontends { app: defaultApp, static: defaultStatic }
changePort :: String -> String
changePort = S.replace (S.Pattern "http://localhost:8000/") (S.Replacement "http://localhost:8008/")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment