Skip to content

Move teleport over to Vite#21168

Merged
ryanclark merged 1 commit intomasterfrom
ryan/vite
Mar 21, 2023
Merged

Move teleport over to Vite#21168
ryanclark merged 1 commit intomasterfrom
ryan/vite

Conversation

@ryanclark
Copy link
Copy Markdown
Member

@ryanclark ryanclark commented Feb 2, 2023

Moves the build process for teleport and teleport.e from Webpack to Vite. This is still a draft as I'm sure there are some bugs to iron out.

Example commands

Build Teleport

As normal -

yarn build-ui

Develop Teleport

Instead of passing through --target, you need to specify your target via PROXY_TARGET. If you're running a proxy locally at localhost:3080, you don't need to specify PROXY_TARGET.

When running the dev server locally, it will try and look for certificates in web/certs. Please follow the instructions in web/README.md to configure HTTPS

yarn start-teleport
PROXY_TARGET=some.other.host.com:3080 yarn start-teleport-e

If you use my development environment, you can switch over to the vite branch to test this out.

Comment thread web/packages/build/vite/html.ts Outdated

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that overlaps with 0-9 in the same character class, and is equivalent to \[.\/0-9:;<=\].
Comment thread web/packages/build/vite/html.ts Outdated

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that overlaps with 0-9 in the same character class, and is equivalent to \[.\/0-9:;<=\].
@ryanclark ryanclark force-pushed the ryan/vite branch 2 times, most recently from dd1062e to 084e885 Compare February 2, 2023 21:17
Comment thread web/packages/build/vite/html.ts Fixed
@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Feb 2, 2023

It would be cool if we could somehow detect https_keypairs from teleport.yaml rather than generating a separate set of certs for the dev server, but I guess that would require we somehow tell vite where the teleport config is.

I tried to run locally and it looks like the dev server starts, but I get an SSL protocol error when connecting from Chrome.

VITE_TARGET=localhost:3080 VITE_HTTPS_CERT=~/t/proxy.127.0.0.1.nip.io+4.pem VITE_HTTPS_KEY=~/t/proxy.127.0.0.1.nip.io+4-key.pem yarn start-teleport
yarn run v1.22.19
$ yarn workspace @gravitational/namespaces start-teleport
$ yarn workspace @gravitational/teleport start
$ vite

  VITE v4.0.4  ready in 391 ms

  ➜  Local:   https://localhost:3000/
  ➜  Network: https://192.168.1.136:3000/
  ➜  press h to show help

@strideynet
Copy link
Copy Markdown
Contributor

As of the fix introduced in f6dedd5 this now works on my machine where I run teleport on a domain name that is not localhost :D

@ryanclark ryanclark force-pushed the ryan/vite branch 2 times, most recently from ef6b656 to 93514ee Compare February 9, 2023 11:59
Comment thread web/packages/build/vite/html.ts Outdated

get(
`https://${target}/web`,
{ headers, rejectUnauthorized: false },

Check failure

Code scanning / CodeQL

Disabling certificate validation

Disabling certificate validation is strongly discouraged.
@ryanclark ryanclark force-pushed the ryan/vite branch 2 times, most recently from db83044 to 55f8c4b Compare February 21, 2023 13:45
@ryanclark ryanclark marked this pull request as ready for review February 21, 2023 14:11
@ryanclark ryanclark force-pushed the ryan/vite branch 5 times, most recently from 5eabefb to 5a623df Compare February 21, 2023 16:23
@ravicious
Copy link
Copy Markdown
Member

Do you happen to have some stats on how it affects the size of compiled assets?

@public-teleport-github-review-bot
Copy link
Copy Markdown

@ryanclark - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes.

@ryanclark ryanclark force-pushed the ryan/vite branch 2 times, most recently from 970dad9 to 431673f Compare February 22, 2023 16:42
@gzdunek
Copy link
Copy Markdown
Contributor

gzdunek commented Feb 23, 2023

I have two issues:

  • without VITE_SKIP_SSL I get:
grzegorz@mbp teleport % VITE_TARGET=localhost:3080 yarn start-teleport 
yarn run v1.22.19
$ yarn workspace @gravitational/teleport start
$ vite
error when starting dev server:
Error: Command failed: "/Users/grzegorz/.vite-plugin-mkcert/mkcert" -CAROOT
/bin/sh: /Users/grzegorz/.vite-plugin-mkcert/mkcert: is a directory

    at ChildProcess.exithandler (node:child_process:402:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Socket.<anonymous> (node:internal/child_process:458:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:301:12)
  • with VITE_SKIP_SSL=yes I can't log in (access denied). I found this in logs:
2023-02-23T13:49:09+01:00 WARN [WEB]       http: named cookie not present request:GET /web web/apiserver.go:3399
2023-02-23T13:49:10+01:00 WARN [WEB]       http: named cookie not present request:GET /web web/apiserver.go:3399
2023-02-23T13:49:15+01:00 WARN             "unable to validate CSRF token unable to extract CSRF token from cookie\n\thttp: named cookie not present" httplib/httplib.go:145

Is something misconfigured on my end?

@ryanclark ryanclark force-pushed the ryan/vite branch 4 times, most recently from fddbe2d to 286e0b5 Compare March 15, 2023 16:58
@gzdunek
Copy link
Copy Markdown
Contributor

gzdunek commented Mar 16, 2023

Connect seems to work fine, but I can't login to the Web UI :(

I still get Access denied and I see this in logs:

2023-03-16T10:14:39+01:00 WARN [WEB]       http: named cookie not present request:GET /web web/apiserver.go:3472
2023-03-16T10:14:45+01:00 WARN             "unable to validate CSRF token unable to extract CSRF token from cookie\n\thttp: named cookie not present" httplib/httplib.go:146

@ryanclark could you try clearing cookies and then logging in?

Comment thread web/README.md Outdated
@ryanclark ryanclark force-pushed the ryan/vite branch 3 times, most recently from 439295f to 526eb50 Compare March 16, 2023 16:10
Copy link
Copy Markdown
Contributor

@kimlisa kimlisa left a comment

Choose a reason for hiding this comment

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

working great so far, except for that one bug.

can we also update outdated default ports on our web/README file? eg: mfa stuff

another thing is when i run yarn build-ui, an extra file gets created in the web/teleport/.swc file (idk what it is or if we need it):

image

Comment thread web/README.md Outdated
Comment on lines 118 to 119
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not true, i tested it by setting up github for local use and it works. this was also supported before as well. other connectors might not work for local, i think there was another one that worked for local use but can't remember (i favor github for testing b/c it's the easiest to set up)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was there already - shall I remove this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh i see, yeah i'd remove it

Comment thread web/packages/design/src/StepSlider/StepSlider.tsx Outdated
Comment thread web/packages/teleport/src/Player/ProgressBar/Slider/Slider.jsx Outdated
@ryanclark ryanclark force-pushed the ryan/vite branch 2 times, most recently from 53bec97 to c8f0a7c Compare March 20, 2023 15:27
Copy link
Copy Markdown
Contributor

@hatched hatched left a comment

Choose a reason for hiding this comment

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

Thanks for keeping up with this, this is a huge build speed improvement! 👍

Copy link
Copy Markdown
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

This is so fast. 😵‍💫

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from zmb3 March 21, 2023 16:35
@ryanclark ryanclark force-pushed the ryan/vite branch 2 times, most recently from c079b9f to 1d03a5d Compare March 21, 2023 16:46
@ryanclark ryanclark added this pull request to the merge queue Mar 21, 2023
@ryanclark ryanclark merged commit 471a82b into master Mar 21, 2023
@ryanclark ryanclark deleted the ryan/vite branch March 21, 2023 18:26
@ravicious
Copy link
Copy Markdown
Member

The css attribute doesn't appear to be handled correctly in stories. Compare the Quick Input Suggestions story between 471a82b and its parent. The css attribute of the div returned by QuickInputListWrapper is not processed in any way and is just inserted verbatim into the HTML.

IIRC there were some problems with Vite and styled-components, right? Though Storybook still uses Webpack so idk what's going on here. 🤔

@ryanclark
Copy link
Copy Markdown
Member Author

@ravicious #23427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants