-
Notifications
You must be signed in to change notification settings - Fork 129
Build process #52
Comments
Hey sharpcoder28, good question! The docs here hopefully explain some of the problems and solutions for creating a large, microserviced frontend with single-spa. Let me know if they help, or if they could be improved! About your specific questions, though:
It sounds like you're using angular-cli to build at least one of the single-spa applications? The example here in single-spa-examples actually does not use angular-cli, which is why you can't find it in this repo. You can check out single-spa-angular-cli, which is a library that helps you get things set up with angular-cli apps. It also explains how they fit into the single-spa world. The basic approach taken in that project is that ng build produces a bundle that creates a global variable for your single-spa application. Your singleSpa.registerApplication calls go through the library and lazily download the bundles for each of the applications that were built by angular-cli.
I'm not sure what you mean here, could you clarify? Are you talking about the |
I tried single-spa-angular-cli, all kinds of issues. From the start it says "In the child application" what child application? And then in the app entry file? What file? I'm guessing you mean for us to create one. That link is a 404. The if I follow to run examples locally, first of all the git clone is a bad url. Running npm start throws an error. Npm start in the /src/menu throws an error, have to install @angular/dev something. Same thing for the other folders. The it says to add an angular cli apps, app1, but that already exists. How do I run the root application with all of the components working? |
@robinComa could you comment on this one, since you maintain single-spa-angular-cli? (Also, THANK YOU for being so great at helping me field some of these questions. It's a huge help for me, since I'm not an expert in Angular) |
Hello @sharpcoder28 and @joeldenning To use an ng cli apps with single spas, it is really simple. And after you have to change somethings inside your angular app :
And remove zone.js :
And add zone.js only for your cli app (to run it outside the portal :
After it, you can use the ng build --prod to build your cli app, I recommend for the moment to use : Now you can use single spa all usual :
The only tricks to run your app on cli and single spa is to add this on your single spa index.html:
For more information, see the doc : Is it more clear? @joeldenning no problem to help you when I can! |
Did a normal git clone, and I still get that error above about build/common.js. Are you missing a webpack build in the tutorial? Ran npm run preinstall and it still didn't help |
@sharpcoder28 I tried to run single-spa-angular-cli-examples as well a couple days ago and ran into issues as well. The error that you screenshotted above is the same one that I saw because the locally install angular-cli wasn't working correctly. I submitted PlaceMe-SAS/single-spa-angular-cli-examples#2 to fix the issues that I saw. Here were some of the things I had to do to get things working:
I also ran into issues using the local version of angular-cli for each of the builds. So I changed it to use the globally installed version of angular-cli and that seemed to work better. If you have trouble getting any of the builds to work, try running Can you try doing a |
Thanks! I got it working. I'm going to prototype a build process soon, but I'm pretty confident. Do you see any issue in having the apps build and just drop into the dist folder of the main running app? I testing it and didn't need to do a build in the host app. Not unless a new child app was added. |
@sharpcoder28 happy to hear it's working! Yes, as long as you don't change anything in the main file or the the loaders directory, you don't have to re-build the root application (or "host app") |
How would this work in production? If I have apps in different repos, I need to build (i.e. ng build --prod) which produces bundled files with random names, and then dump the output into respective folders. Also what's up with the reference to .ts files?
The text was updated successfully, but these errors were encountered: