-
Notifications
You must be signed in to change notification settings - Fork 72
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
log-viewer-webui: Add boilerplate React client. #468
log-viewer-webui: Add boilerplate React client. #468
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it looks good to me. There are some devDependencies
that are specified but I do not see the usages of those in the webpack config file. If those are to be configured later, can we submit those another PR?
"lint:check": "npx eslint --no-eslintrc --config package.json src webpack.config.js", | ||
"lint:fix": "npx eslint --fix --no-eslintrc --config package.json src webpack.config.js", | ||
"build": "webpack --define-process-env-node-env production", | ||
"watch": "webpack serve" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, can we rename this config as start
? Let's continue the discussion in server/package.json
.
"version": "0.1.0", | ||
"description": "", | ||
"main": "src/main.js", | ||
"scripts": { | ||
"dev": "NODE_ENV=development nodemon src/main.js", | ||
"lint:check": "npx eslint --no-eslintrc --config package.json src", | ||
"lint:fix": "npx eslint --fix --no-eslintrc --config package.json src", | ||
"start": "NODE_ENV=production node src/main.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to rename this script as prod
and the one below for development as start
? That way we will be consistently using start
as the name for all development scripts across all repos.
"@babel/preset-env": "^7.24.7", | ||
"@babel/preset-react": "^7.24.7", | ||
"@webpack-cli/generators": "^3.0.7", | ||
"autoprefixer": "^10.4.19", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems handy, but it seems not only we need to configure "browserslist"
in this package.json file but also we need to install postcss
and add some related config in webpack.config.js according to their docs: https://github.com/postcss/autoprefixer#webpackhttps://github.com/postcss/autoprefixer#webpack
(Did I miss anything? )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I did have postcss initially, but had some issues so I removed it but forgot to remove this.
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-transform-runtime": "^7.24.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see those getting configured in webpack.config.js. Mind sharing what the usages are of those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, didn't clean up package.json properly.
"@babel/plugin-transform-runtime": "^7.24.7", | ||
"@babel/preset-env": "^7.24.7", | ||
"@babel/preset-react": "^7.24.7", | ||
"@webpack-cli/generators": "^3.0.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto - why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we just need "webpack-cli": "^5.1.4",
?
"eslint-config-yscope": "latest", | ||
"html-webpack-plugin": "^5.6.0", | ||
"mini-css-extract-plugin": "^2.9.0", | ||
"prettier": "^3.3.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add a config file for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
]; | ||
|
||
const config = { | ||
devtool: isProduction ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the devServer
config to be added in a future PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I read the docs incorrectly, but it seemed like the defaults worked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the defaults do work, but do we want to be explicit about which port to use? Also, similar to HMR, do we want to enable "Fast Refresh" with https://github.com/pmmmwh/react-refresh-webpack-plugin ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think the port defaults to
'auto'
which seems like it would be more flexible than specifying it explicitly (and the CLI prints out what it chose). - We could add
open
if you like (I prefer not automatically opening the browser, but that's just me). - What does that plugin do compared to the default dev server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the port defaults to 'auto' which seems like it would be more flexible than specifying it explicitly (and the CLI prints out what it chose).
Gotcha. Let's leave it as is then.
We could add open if you like (I prefer not automatically opening the browser, but that's just me).
I don't have a preference so I'm fine leaving it as false
.
What does that plugin do compared to the default dev server?
It's for preserving states of any modified React components. e.g. Say we are modifying a button in a modal window, with conventional HMR the modal window will be closed when the page auto reloads. With Fast Refresh, the modal window will remain open without us clicking again in the browser. Another example is with Fast Refresh, any existing text input is preserved in a text field when the page auto reloads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks.
}, | ||
output: { | ||
path: path.resolve(dirname, "dist"), | ||
filename: "[name].[contenthash].bundle.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contenthash has been causing issues with HMR / Fast Refresh in my experience and I recommend removing such in a dev environment setting.
filename: "[name].[contenthash].bundle.js", | |
filename: isProduction? | |
"[name].[contenthash].bundle.js": | |
"[name].bundle.js", |
"version": "0.1.0", | ||
"description": "", | ||
"main": "src/main.js", | ||
"scripts": { | ||
"dev": "NODE_ENV=development nodemon src/main.js", | ||
"prod": "NODE_ENV=production node src/main.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's alphabetize these.
Co-authored-by: Junhao Liao <[email protected]>
Co-authored-by: Junhao Liao <[email protected]>
Co-authored-by: Junhao Liao <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. The PR title is fine for the squashed commit message.
Co-authored-by: Junhao Liao <[email protected]>
Description
Following #442, this PR adds a boilerplate client written using React.
For consistency, the server's
package.json
was also changed to:log-viewer-webui-server
npm run watch
Validation performed
npm lint:check
passes.npm run watch
starts a local HTTP server that keeps track of source changes.npm run build
builds a bundle indist
that can be served withnpx http-server dist