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

Extend docs on how to write a custom devServer #5211

Merged
merged 10 commits into from
Apr 26, 2023

Conversation

fochlac
Copy link
Contributor

@fochlac fochlac commented Apr 24, 2023

  • switch section on custom index html file and dev server, so it's already explained when mentioning it in the dev-server-section
  • add a minimal example for the test-kickstart-script
  • update documentation of the parameters
  • add some explanation on the role of the dev-server

@netlify
Copy link

netlify bot commented Apr 24, 2023

👷 Deploy request for cypress-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 32f34e4

@CLAassistant
Copy link

CLAassistant commented Apr 24, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job reverse engineering this!

server.

```ts
interface DevServerOptions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - we should probably expose this via Cypress.DevServerOptions in the future to help guide third parties.

const absolute = CypressInstance.config('supportFile')
const relative = absolute.replace(CypressInstance.config('projectRoot'), '')
const relativeUrl = `${devServerPublicPathRoute}${relative}`
imports.push({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a closer look into the load mechanism, and this format causes the script to be loaded twice:
https://github.com/cypress-io/cypress/blob/7a33f5c1a87f5a3aa3b8da575b39e42f93bfd5db/packages/driver/src/cypress/script_utils.ts#L6
First it will be fetched in the fetchScript function, and later in evalScripts the load-function is triggered, wich causes the import to fetch the contents again.

It's propably better to just pass the importFunctions and use the alternative path here: https://github.com/cypress-io/cypress/blob/7a33f5c1a87f5a3aa3b8da575b39e42f93bfd5db/packages/driver/src/cypress/script_utils.ts#L49

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This propably should be fixed for the vite-dev-server as well

* switch section on custom index html file and dev server, so it's already explained when mentioning it in the dev-server-section
* add a minimal example for the test-kickstart-script
* update documentation of the parameters
* add some explanation on the role of the dev-server
 * add links to code-examples
 * add sample file server
 * extend client script to also show import of support file
Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Quick few nits and we are good to go. Thanks, this looks great!

Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
@lmiller1990 lmiller1990 self-requested a review April 26, 2023 22:39
@lmiller1990
Copy link
Contributor

Thanks 🎉

@lmiller1990 lmiller1990 merged commit 4de9feb into cypress-io:main Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants