Skip to content

hasanayan/craco-plugin-single-spa-application

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

craco-plugin-single-spa-application

Convert your CRA project into a single-spa application without ejecting and losing update support of react-scripts

Dependencies

This plugins depends on CRACO so make sure to follow the installation instructions before installing and setting up this plugin. https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#installation

Install

npm install craco-plugin-single-spa-application --save-dev

Usage

  1. Open the craco.config.js file and apply the following changes:
const SingleSpaAppcracoPlugin = require('craco-plugin-single-spa-application');

const singleSpaAppPlugin = {
  plugin: SingleSpaAppcracoPlugin,
  options: {
    orgName: "my-org",
    projectName: "my-app",
    entry: "src/single-spa-index.tsx", //defaults to src/index.js,
    orgPackagesAsExternal: false, // defaults to false. marks packages that has @my-org prefix as external so they are not included in the bundle
    reactPackagesAsExternal: true, // defaults to true. marks react and react-dom as external so they are not included in the bundle
    minimize: false, // defaults to false, sets optimization.minimize value
    outputFilename: "single-spa-build.js" // defaults to the values set for the "orgName" and "projectName" properties, in this case "my-org-my-app.js"
  },
}

// Keep any other configuration you are exporting from CRACO and add the plugin to the plugins array
module.exports = {
    plugins: [singleSpaAppPlugin]
}
  1. Run npm run craco:build to generate your microfrontend app bundle. The output will be located under build folder and named as my-org-my-app.js or using the name defined in outputFilename option.

License

Licensed under the MIT License, Copyright ©️ 2021 Hasan Ayan. See LICENSE.md for more information.

About

Convert your CRA4 project into a single-spa application without ejecting and losing update support of react-scripts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •