Skip to content

Commit

Permalink
Merge pull request #22 from hasanayan/fix-readme
Browse files Browse the repository at this point in the history
chore: fix readme
  • Loading branch information
felipeplets authored May 11, 2022
2 parents 8ff1b39 + b20df4f commit 4354662
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Convert your CRA project into a single-spa application without ejecting and losi
![](https://img.shields.io/npm/v/craco-plugin-single-spa-application.svg?style=flat)
![](https://img.shields.io/npm/dt/craco-plugin-single-spa-application.svg?style=flat)

## 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

```
Expand All @@ -13,40 +17,31 @@ npm install craco-plugin-single-spa-application --save-dev

## Usage

1. Add the plugin into your craco.config.js;
1. Open the `craco.config.js` file and apply the following changes:

```typescript
singleSpaApplicationPlugin = require('craco-plugin-single-spa-application');

module.exports = {
plugins: [{
plugin: singleSpaApplicationPlugin,
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"
},
}]
const singleSpaApplicationPlugin = {
plugin: singleSpaApplicationPlugin,
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"
},
}
```

2. Update the scripts section of your package.json as follows:

```json
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"craco:build": "craco build",
"craco:start": "craco start",
...
// Keep any other configuration you are exporting from CRACO and add the plugin to the plugins array
module.exports = {
plugins: [singleSpaApplicationPlugin]
}
```

3. 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
2. 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

Expand Down

0 comments on commit 4354662

Please sign in to comment.