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 fedx-scripts serve #404

Merged
merged 6 commits into from
Jul 18, 2023
Merged

feat: add fedx-scripts serve #404

merged 6 commits into from
Jul 18, 2023

Conversation

adamstankiewicz
Copy link
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

@@ -35,7 +35,7 @@
"@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
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
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
👍🏽

@@ -1,4 +1,7 @@
#!/usr/bin/env node

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

package.json Outdated Show resolved Hide resolved
davidjoy
davidjoy previously approved these changes Jun 27, 2023
Copy link
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
Copy link
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
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.

👍🏽

package.json Outdated Show resolved Hide resolved
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
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
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

🎉 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