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

feat: add frontend build #350

Merged
merged 2 commits into from
Jun 27, 2024
Merged

Conversation

kwatkins-ld
Copy link

Requirements

Adding a frontend build for the devserver

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.

@kwatkins-ld kwatkins-ld changed the base branch from main to moonshot-ld-dev-server June 27, 2024 20:05
@@ -17,6 +17,9 @@ import './App.css';
import { useEffect, useState } from 'react';
import { Icon } from '@launchpad-ui/icons';

Copy link
Author

Choose a reason for hiding this comment

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

We use paths like /api/dev/projects/:projectKey in local dev, because the /api prefix triggers proxy-matching behavior in the frontend devserver to forward the requests to the API service.

We want paths like /dev/projects/:projectKey in the published CLI, because the API server is also serving the frontend. Toggle this behavior using meta data from the Vite build.

const plugins: PluginOption[] = [react(), svgr()];

if (command === 'build') {
plugins.push(viteSingleFile());
Copy link
Author

@kwatkins-ld kwatkins-ld Jun 27, 2024

Choose a reason for hiding this comment

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

Inline everything into a single HTML when running a production build, for the local dev loop just use the defaults.

@@ -5,7 +5,7 @@ import (
"net/http"
)

//go:embed index.html
//go:embed dist/index.html
Copy link
Author

@kwatkins-ld kwatkins-ld Jun 27, 2024

Choose a reason for hiding this comment

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

@mike-zorn the output of Vite by default is {repo_root}/internal/dev_server/ui/dist/* because we run the build command from {repo_root}/internal/dev_server/ui... as a result I had to change this embed pattern, and when browsing to localhost:8765/ui I see a list of filesystem contents (guessing this is the static file serving middleware?)

..browsing to localhost:8765/ui/dist results in the {repo_root}/internal/dev_server/ui/dist/index.html file being served as expected, but I don't think we want the "dist" portion of the path? Not a big deal, just noting for posterity

Copy link
Author

Choose a reason for hiding this comment

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

We also made the decision not to introduce the frontend build into the build pipeline at this point, because we'll need to update the GH Action to use node/npm to run npm run build.

...for now, let's just run npm run build locally and check in the artifact.

Copy link
Contributor

Choose a reason for hiding this comment

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

Took a look. I think I see how to fix it. I'll add a commit to the PR.

Copy link
Author

Choose a reason for hiding this comment

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

Pulled the change down and tested, looks good. Thanks! 🙌

Copy link
Contributor

@mike-zorn mike-zorn left a comment

Choose a reason for hiding this comment

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

🙌🏻

@kwatkins-ld kwatkins-ld merged commit d81e962 into moonshot-ld-dev-server Jun 27, 2024
1 check passed
@kwatkins-ld kwatkins-ld deleted the kwatkins/frontend-build branch June 27, 2024 20:54
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.

2 participants