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

build: enable websocket and hot module reload #136

Merged
merged 1 commit into from
Jun 6, 2024
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
18 changes: 13 additions & 5 deletions confs/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down
97 changes: 76 additions & 21 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions frontend/web-dev-server.config.js
Original file line number Diff line number Diff line change
@@ -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)) {
Expand All @@ -16,6 +17,9 @@ export default {
rootDir: 'public/',
basePath: '/static',
plugins: [
hmrPlugin({
include: ['src/**/*'],
}),
legacyPlugin({
polyfills: {
// Manually imported in index.html file
Expand Down