npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-microfrontend-cli

v1.2.0

Published

A CLI tool to create multiple React projects with microfrontend architecture using Vite

Downloads

44

Readme

Vite Microfrontend CLI

A command-line interface tool for quickly setting up microfrontend projects using Vite and Module Federation with React.

Features

  • Create a main host application
  • Generate multiple microfrontend projects
  • Automatically configure Vite and Module Federation
  • Set up basic React components for each microfrontend
  • Create a workspace structure for easy management of all projects

Usage

To use the CLI tool, navigate to your preferred directory in your terminal and run:

npx vite-microfrontend-cli <main-project-name> [options]

Arguments

| Argument | Description | | --------------------- | ----------------------------------- | | <main-project-name> | Name of the main project (required) |

Options

| Option | Description | | ----------------------- | ----------------------------------------------- | | -n, --number <number> | Number of microfrontends to create (default: 1) |

Example

To create a main project named "my-app" with 3 microfrontends:

npx vite-microfrontend-cli my-app -n 3

This will:

  1. Prompt you for names for each microfrontend project
  2. Create a workspace directory named my-app-workspace
  3. Create the specified number of microfrontend projects within the workspace
  4. Create the main host application within the workspace
  5. Set up Vite configuration for each project
  6. Configure Module Federation
  7. Create basic React components
  8. Set up a parent package.json for managing all projects

Project Structure

After running the command, you'll have the following project structure:

my-app-workspace/
├── package.json
├── my-app-host/           # Main host application
├── my-app-microfrontend1/ # First microfrontend
├── my-app-microfrontend2/ # Second microfrontend
└── my-app-microfrontend3/ # Third microfrontend

Each project will be set up with Vite and configured for Module Federation.

Development

To start development, navigate to the workspace directory and run:

npm run preview-all

Remember to run the remote application and host application in Preview mode when developing instead of Development mode to get the file serving working.

so running npx vite-microfrontend-cli <main-project-name> [options] installs dependencies for all projects, builds them. You don't need to run npm run install-all or npm run build-all separately unless you want to perform these steps individually.

If you do want to run the steps separately, you can use:

npm run install-all
npm run build-all
npm run preview-all

You can also manage each project individually:

  1. Navigate to a specific project folder (e.g., cd my-app-host or cd my-app-microfrontend1)
  2. Run the following commands as needed:
npm install    # Install dependencies for this project
npm run build  # Build this project
npm run dev    # Start the development server for this project

Building for Production

To build all projects for production, run:

npm run build-all

in the workspace directory.

Type check

To type check and catch errors early, run:

npm run type-check

in the workspace directory.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Troubleshooting

If you encounter any issues during setup or execution, please check the following:

  1. Ensure you have the latest version of Node.js and npm installed.
  2. Make sure you have sufficient permissions to create directories and install packages.
  3. You can connect with me at https://www.linkedin.com/in/ujjwal-tiwari202/

Author

Ujjwal Tiwari

License

This project is licensed under the MIT License.