Skip to content

feat: add fedx-scripts serve#404

Merged
adamstankiewicz merged 6 commits into
masterfrom
ags/server
Jul 18, 2023
Merged

feat: add fedx-scripts serve#404
adamstankiewicz merged 6 commits into
masterfrom
ags/server

Conversation

@adamstankiewicz
Copy link
Copy Markdown
Member

@adamstankiewicz adamstankiewicz commented Jun 24, 2023

Description

These changes propose adding a serve command to the fedx-scripts CLI such that consumers can create an NPM script to serve the production Webpack build from the generated dist directory when running npm run build. By serving the production build locally, engineers can have more confidence in their resulting production builds before it reaches a staging/production environment.

As is, there is no documented way to preview a production build of micro-frontends of the files in the dist directory. Simply opening the index.html does not work as the React routing breaks, amongst other issues.

The proposed serve command starts an Express.js serve running on the PORT setting defined in env.config.js. Note: the .env* files to configuration is now deprecated so the serve command is intentionally not supporting it.

ADR

README documentation

Comment thread package.json
"@babel/preset-react": "7.22.5",
"@edx/eslint-config": "3.2.0",
"@edx/new-relic-source-map-webpack-plugin": "2.1.0",
"@fullhuman/postcss-purgecss": "^5.0.0",
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.

Pins some dependencies, since majority of dependencies are pinned.

@adamstankiewicz adamstankiewicz marked this pull request as ready for review June 26, 2023 23:10
brobro10000
brobro10000 previously approved these changes Jun 27, 2023
Copy link
Copy Markdown
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

Sad to see that the .env* isn't supported, but maybe the catalyst needed to start transitioning to env.config.js across other MFEs
👍🏽

Comment thread bin/fedx-scripts.js
@@ -1,4 +1,7 @@
#!/usr/bin/env node

const chalk = require('chalk');
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.

Love me some chalk. 😋

Comment thread package.json Outdated
davidjoy
davidjoy previously approved these changes Jun 27, 2023
Copy link
Copy Markdown
Contributor

@davidjoy davidjoy left a comment

Choose a reason for hiding this comment

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

Love it. :shipit:

@adamstankiewicz adamstankiewicz dismissed stale reviews from davidjoy and brobro10000 via a4bd289 July 17, 2023 21:23
@adamstankiewicz
Copy link
Copy Markdown
Member Author

adamstankiewicz commented Jul 17, 2023

@davidjoy @brobro10000 I've updated this PR to add support for finding PORT from either .env.development|private file(s) or an env.config.js file. Please take another look when you get a chance!

brobro10000
brobro10000 previously approved these changes Jul 18, 2023
Copy link
Copy Markdown
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

👍🏽

Comment thread package.json Outdated
Comment thread lib/scripts/serve.js
Comment on lines +9 to +18
// Add process env vars. Currently used only for setting the
// server port and the publicPath
dotenv.config({
path: path.resolve(process.cwd(), '.env.development'),
});

// Allow private/local overrides of env vars from .env.development for config settings
// that you'd like to persist locally during development, without the risk of checking
// in temporary modifications to .env.development.
resolvePrivateEnvConfig('.env.private');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🥳 , but good stepping stone to transition over to env.config.js

Copy link
Copy Markdown
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

Third times the charm!

@adamstankiewicz adamstankiewicz merged commit 5b96343 into master Jul 18, 2023
@adamstankiewicz adamstankiewicz deleted the ags/server branch July 18, 2023 14:25
@edx-semantic-release
Copy link
Copy Markdown

🎉 This PR is included in version 12.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

muselesscreator pushed a commit that referenced this pull request Aug 1, 2023
* feat: add serve command to fedx-scripts to run production bundle
* docs: add ADR about serve command
* feat: support .env.development and .env.private
* docs: update ADR to include .env* support
* chore: update package-lock.json take 3
* chore: pin express devDep
muselesscreator pushed a commit that referenced this pull request Aug 7, 2023
* feat: add serve command to fedx-scripts to run production bundle
* docs: add ADR about serve command
* feat: support .env.development and .env.private
* docs: update ADR to include .env* support
* chore: update package-lock.json take 3
* chore: pin express devDep
muselesscreator pushed a commit that referenced this pull request Aug 31, 2023
* feat: add serve command to fedx-scripts to run production bundle
* docs: add ADR about serve command
* feat: support .env.development and .env.private
* docs: update ADR to include .env* support
* chore: update package-lock.json take 3
* chore: pin express devDep
muselesscreator pushed a commit that referenced this pull request Aug 31, 2023
* feat: add serve command to fedx-scripts to run production bundle
* docs: add ADR about serve command
* feat: support .env.development and .env.private
* docs: update ADR to include .env* support
* chore: update package-lock.json take 3
* chore: pin express devDep
muselesscreator pushed a commit that referenced this pull request Aug 31, 2023
* feat: add serve command to fedx-scripts to run production bundle
* docs: add ADR about serve command
* feat: support .env.development and .env.private
* docs: update ADR to include .env* support
* chore: update package-lock.json take 3
* chore: pin express devDep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants