diff --git a/confs/nginx.conf b/confs/nginx.conf index fec78878..9f2403ee 100644 --- a/confs/nginx.conf +++ b/confs/nginx.conf @@ -29,8 +29,8 @@ server { # web server dev has specific urls, we want to redirect them to static rewrite ^/(__wds-|__web-dev-server)(.*)$ /static/$1$2 last; - # Temporary hack: redirect bundled to base js for dev + # we need a regexp, because we use a regexp below, and it would have priority location /static${DEV_UI_SUFFIX}/search-a-licious.bundled.js { return 302 $scheme://$http_host/static/dist/search-a-licious.js; } @@ -41,10 +41,18 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; set $search_nodejs search_nodejs; - # rewrite to get rid of /static - # double $ to avoid being interpreted by interpolation - # rewrite ^/static${DEV_UI_SUFFIX}/(.*)$ /$1 break; - # important do not add a / at the end for node is picky on not having '//' in url + proxy_pass http://$search_nodejs:8000; + } + # web socket - in DEV only = node server + location ~* /wds${DEV_UI_SUFFIX} { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_http_version 1.1; + # websocket enabling options + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + set $search_nodejs search_nodejs; proxy_pass http://$search_nodejs:8000; } # Static files - in PROD = files on disk diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 8b56d7aa..233b7040 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -9,12 +9,11 @@ "version": "2.0.1", "license": "BSD-3-Clause", "dependencies": { - "@types/lodash-es": "^4.17.0", - "lit": "^3.0.0", - "lodash-es": "^4.17.21" + "lit": "^3.0.0" }, "devDependencies": { "@custom-elements-manifest/analyzer": "^0.6.3", + "@open-wc/dev-server-hmr": "^0.1.2-next.0", "@open-wc/testing": "^3.1.5", "@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-replace": "^5.0.2", @@ -2225,6 +2224,68 @@ "integrity": "sha512-Sj7gKl1TLcDbF7B6KUhtvr+1UCxdhMbNY5KxdU5IfMFWqL8oy1ZeAcCANjoB1TL0AJTcPmcCFsCbHf8X2jGDUA==", "dev": true }, + "node_modules/@open-wc/dev-server-hmr": { + "version": "0.1.2-next.0", + "resolved": "https://registry.npmjs.org/@open-wc/dev-server-hmr/-/dev-server-hmr-0.1.2-next.0.tgz", + "integrity": "sha512-XgazcRuYE0J17X1LgZ/BumwMf81p7qR1h3ncc3ljA3PDqXIBSOYnt1SSoR/IqlJvDmbTopONYQ/w+qjEOtBrAg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-import-assertions": "^7.12.1", + "@babel/plugin-syntax-top-level-await": "^7.12.1", + "@web/dev-server-core": "^0.3.10", + "@web/dev-server-hmr": "^0.1.6", + "picomatch": "^2.2.2" + } + }, + "node_modules/@open-wc/dev-server-hmr/node_modules/@web/dev-server-core": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.3.19.tgz", + "integrity": "sha512-Q/Xt4RMVebLWvALofz1C0KvP8qHbzU1EmdIA2Y1WMPJwiFJFhPxdr75p9YxK32P2t0hGs6aqqS5zE0HW9wYzYA==", + "dev": true, + "dependencies": { + "@types/koa": "^2.11.6", + "@types/ws": "^7.4.0", + "@web/parse5-utils": "^1.2.0", + "chokidar": "^3.4.3", + "clone": "^2.1.2", + "es-module-lexer": "^1.0.0", + "get-stream": "^6.0.0", + "is-stream": "^2.0.0", + "isbinaryfile": "^4.0.6", + "koa": "^2.13.0", + "koa-etag": "^4.0.0", + "koa-send": "^5.0.1", + "koa-static": "^5.0.0", + "lru-cache": "^6.0.0", + "mime-types": "^2.1.27", + "parse5": "^6.0.1", + "picomatch": "^2.2.2", + "ws": "^7.4.2" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@open-wc/dev-server-hmr/node_modules/es-module-lexer": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.3.tgz", + "integrity": "sha512-i1gCgmR9dCl6Vil6UKPI/trA69s08g/syhiDK9TG0Nf1RJjjFI+AzoWW7sPufzkgYAn861skuCwJa0pIIHYxvg==", + "dev": true + }, + "node_modules/@open-wc/dev-server-hmr/node_modules/isbinaryfile": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", + "dev": true, + "engines": { + "node": ">= 8.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/gjtorikian/" + } + }, "node_modules/@open-wc/scoped-elements": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/@open-wc/scoped-elements/-/scoped-elements-2.2.4.tgz", @@ -2638,19 +2699,6 @@ "@types/koa": "*" } }, - "node_modules/@types/lodash": { - "version": "4.17.0", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz", - "integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==" - }, - "node_modules/@types/lodash-es": { - "version": "4.17.12", - "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", - "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", - "dependencies": { - "@types/lodash": "*" - } - }, "node_modules/@types/mime": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", @@ -3083,6 +3131,18 @@ "integrity": "sha512-pqrTKmwEIgafsYZAGw9kszYzmagcE/n4dbgwGWLEXg7J4QFJVQRBld8j3Q3GNez79jzxZshq0bcT962QHOghjw==", "dev": true }, + "node_modules/@web/dev-server-hmr": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@web/dev-server-hmr/-/dev-server-hmr-0.1.12.tgz", + "integrity": "sha512-oqEYVFAh9D74GUigQqxPN5izhocc+A02tZ7Y4QCIHLe6qttjD5R+Hpj8CAObySslfH1X/IGSsWhB8TGctCxlPA==", + "dev": true, + "dependencies": { + "@web/dev-server-core": "^0.4.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/@web/dev-server-legacy": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@web/dev-server-legacy/-/dev-server-legacy-1.0.3.tgz", @@ -6605,11 +6665,6 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, - "node_modules/lodash-es": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", - "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" - }, "node_modules/lodash.assignwith": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 82197acc..ac918eea 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -45,6 +45,7 @@ }, "devDependencies": { "@custom-elements-manifest/analyzer": "^0.6.3", + "@open-wc/dev-server-hmr": "^0.1.2-next.0", "@open-wc/testing": "^3.1.5", "@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-replace": "^5.0.2", diff --git a/frontend/web-dev-server.config.js b/frontend/web-dev-server.config.js index 1869829e..a15d8d0d 100644 --- a/frontend/web-dev-server.config.js +++ b/frontend/web-dev-server.config.js @@ -1,5 +1,6 @@ import {legacyPlugin} from '@web/dev-server-legacy'; import { rollupPluginHTML as html } from '@web/rollup-plugin-html'; +import { hmrPlugin } from '@open-wc/dev-server-hmr'; const mode = process.env.MODE || 'dev'; if (!['dev', 'prod'].includes(mode)) { @@ -16,6 +17,9 @@ export default { rootDir: 'public/', basePath: '/static', plugins: [ + hmrPlugin({ + include: ['src/**/*'], + }), legacyPlugin({ polyfills: { // Manually imported in index.html file