@cloudhms/craco-plugin-single-spa-application
v1.0.10
Published
Convert your CRA4 project into a single-spa application without ejecting or losing update support of react-scripts
Downloads
4
Maintainers
Readme
craco-plugin-single-spa-application
Convert your CRA4 project into a single-spa application without ejecting and losing update support of react-scripts
Install
npm install craco-plugin-single-spa-application --save-dev
Usage
- Add the plugin into your craco.config.js;
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
externals: ["react-router","react-router-dom"], // defaults to []. marks the specified modules as external so they are not included in the bundle
minimize: false, // defaults to false, sets optimization.minimize value
useHash: false, // use webpack hash to bundle filename
versionName: "1.0.1", use package version to bundle filename
},
}]
}
- Update the scripts section of your package.json as follows:
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"craco:build": "craco build",
"craco:start": "craco start",
...
- 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
License
Licensed under the MIT License, Copyright ©️ 2021 Hasan Ayan. See LICENSE.md for more information.