-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: update webpack config; HugoServer and Webpack Port to be same (3000) #1102
Conversation
Netlify Deployments: |
Lighthouse results: results for https://ocw-hugo-themes-www-pr-1102--ocw-next.netlify.app/:
results for https://ocw-hugo-themes-www-pr-1102--ocw-next.netlify.app/search/:
results for https://ocw-hugo-themes-course-v2-pr-1102--ocw-next.netlify.app/:
|
As @ChristopherChudzicki and @gumaerc explained, Tried to run the tests on development build, but still failed:
Now from here, if I open another chromium window, or even an incognito one, it still fails. On the chromium instance the files are not existing on the eg. One thing that might have to be taken care is also port numbers: if we serve files parallel to playwright test, the served files need to be on the same port. If we run npx serve and then run I also tried using concurrently with something like in package.json: |
tests-e2e/LocalOcw.ts
Outdated
{ | ||
type: "redirect", | ||
match: /^\/static_shared\//, | ||
transform: url => `http://localhost:${env.WEBPACK_PORT}${url}` | ||
transform: url => `http://localhost:$3000${url}` | ||
}, |
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 should be deleted.
When the e2e tests run, the hugo output is served by a static file server using serve-handler
. The static files have structure:
test-sites
|--tmp
|--dist <-- root directory of "overall" static site
|--courses
|--ocw-ci-test-course <-- hugo output of one course site
|--other-course-does-not-exist-yet <-- hugo output of another course site
|--could-add-more
|--ocw-ci-test-www <-- hugo output of root site, ocw-www
Let's say that the tests run on port 3010. Then previously requests to localhost:3010/static_shared/...
had to be redirected to the webpack output. That's what line 185 was doing. We do not need that anymore.
(We do still need to redirect requests to localhost:3010/static_shared
, since static_output
is not at the root of the static site. But that's handled by OCW_WWW_REWRITE
: all requests to localhost:3010/whatever
are redirected to localhost:3010/ocw-ci-test-www/whatever
, except when whatever = courses
.)
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.
Yes you're right - I was experimenting with stuff and I had put it back in. I removed it and that resolved the playwright test for dev side.
@ibrahimjaved12 Thanks for this comment. I suspect the reason you were seeing stuff work better in Chrome than in Chromium is that you probably had some files cached in Chrome. The Incognito Chrome vs Chromium behavior would be identical, I expect. There is one more old webpack dev server thing we can get rid of, then the e2e tests should work with the dev build. See #1102 (comment) We still need to resolve the
Either (2) or (3) seems OK to me. (2) seems maybe slightly preferable, just since the webpack output goes to same location whether dev or prod. @gumaerc @ibrahimjaved12 what do you think? |
I think I might be more inclined towards the (3) option, because of not having an extra config - and I have updated the PR with respect to that. - Is this the kind of implementation you had in mind? But I leave the call for approach to you @ChristopherChudzicki and @gumaerc. With the (2) option, I'm mainly concerned with the necessary changes we would have to make in the depending files to include them both in order to merge them. I get a bit idea that we're adding But if we just add the |
I think (3) is fine 👍 re
If we add On the live site, we want all 2600+1 (+1 = ocw-www) courses using the same webpack output. It saves on s3 uploads (quicker publish). But more importantly, it also means that users can cache the bundle between courses. |
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.
LGTM 👍
Thanks @fakhar-ud-din I'm putting this back to WIP because I found out the Currently figuring this out. |
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.
Tested, working fine.
LGTM 👍
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.
👍 LGTM as well
Pre-Flight checklist
What are the relevant tickets?
#1096
What's this PR do?
This PR updates the webpack configuration for development such that the hugoServer and Webpack port is same(port 3000).
Previously hugoServer was at port 3000, and webpack port at 3001 which caused issues related to dynamic importing. It also introduces webpack watch mode for dev.
How should this be manually tested?
This PR requires to check that the structure is working as intended, and that all the modules used for building the website work fine.
Steps:
yarn fmt
(check that its working)yarn start course
andyarn start www
yarn fmt
again.To test production webpack config:
package.json
Modify line#10:
From:
"start:webpack": "yarn with-env --dev -- webpack --config ./base-theme/assets/webpack/webpack.dev.ts --stats-children",
To:
"start:webpack": "yarn with-env --dev -- webpack --config ./base-theme/assets/webpack/webpack.prod.ts --stats-children",