-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix(cypress/webpack-dev-server): correct path for indexHtmlFile
#27320
Conversation
@@ -78,7 +78,7 @@ export function makeCypressWebpackConfig ( | |||
}, | |||
plugins: [ | |||
new (HtmlWebpackPlugin as typeof import('html-webpack-plugin-5'))({ | |||
template: indexHtmlFile, | |||
template: path.join(projectRoot, indexHtmlFile), |
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 is the fix.
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.
Some tests are failing on this line: https://app.circleci.com/pipelines/github/cypress-io/cypress/54632/workflows/e04d8993-cb44-42a9-9061-e7b37bef32f2/jobs/2257912
Looks like they are missing setting the indexHtmlFile
value
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 I fixed this in b557e6e. If indexHtmlFile
is undefined, we'll just pass undefined like we've been doing. Otherwise we'll call join
to create the path
4c16ed7
to
80b1a39
Compare
@@ -18,6 +18,11 @@ module.exports = { | |||
exclude: /node_modules/, | |||
use: { | |||
loader: 'babel-loader', | |||
options: { |
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 had to add these, I'm not sure why it was not picking up the .babelrc
. Either way, it's unrelated to this bug fix - although there might be another, unrelated issue around babel-loader not automatically finding .babelrc
(that was not introduced by this PR).
If that is an issue, can look into fixing it separately - no bandwidth to go deeper into specifics right now.
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.
Was this working before the changes in this PR? How did you know that babel was not loading correctly? Did you see an error?
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.
It is complaining about not knowing about JSX - I think what's happening is some other part of the toolchain (webpack) expects .babelrc
to exist in the same directory where the process is running, which is now a nested directory (in cypress/
in this case.
I am not sure if this going to impact users. It's likely this is a problem no-one has encountered, since you can't current run with a nested config file, anyway.
Either way, I will create a more minimal project are requested that will side step this issue. Projects using babel and relying on .babelrc
might run into this, but it'll be a separate and unrelated bug...
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 pushed a simple project that won't deal with this. The fact webpack relies on the cwd to find the babelrc
might be an issue but I'm not sure that's even our problem to solve.
Passing run #49411 ↗︎Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
@@ -78,7 +78,7 @@ export function makeCypressWebpackConfig ( | |||
}, | |||
plugins: [ | |||
new (HtmlWebpackPlugin as typeof import('html-webpack-plugin-5'))({ | |||
template: indexHtmlFile, | |||
template: path.join(projectRoot, indexHtmlFile), |
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.
Some tests are failing on this line: https://app.circleci.com/pipelines/github/cypress-io/cypress/54632/workflows/e04d8993-cb44-42a9-9061-e7b37bef32f2/jobs/2257912
Looks like they are missing setting the indexHtmlFile
value
system-tests/project-fixtures/react/cypress/cypress-webpack-dev-server-function.config.ts
Outdated
Show resolved
Hide resolved
fd28b9a
to
7ed762b
Compare
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 👍🏻
* fix(cypress/webpack-dev-server): correct path for `indexHtmlFile` (#27320) * fix: correct path for indexHtmlt * changelog * chore: release @cypress/webpack-dev-server-v3.5.2 [skip ci] * chore: update external dependency paths in binary cleanup (#27460) --------- Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: Adam Stone-Lord <adams@cypress.io>
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
We are not passing the correct path to the
indexHtmlFile
. Ifcypress.config.js
is not in the root of the project, the path is wrong and webpack errors.Steps to test
I added a test. Alternatively test against my minimal reproduction https://github.com/lmiller1990/cypress-test-tiny/compare/master...lmiller1990:cypress-test-tiny:issue-26400?expand=1
How has the user experience changed?
Can have
cypress.config
in a directory that is not the root of the project.PR Tasks
cypress-documentation
?type definitions
?