| title | Getting Started |
|---|---|
| order | 200 |
| lang | en |
Welcome to Scully!
Before getting started, please read the Prerequisites.
All about Scully in one video : Building the Fastest Angular Apps Possible
This getting started guide covers the following topics:
First, open an Angular application's path in your terminal and run the following command:
ng add @scullyio/initAfter a successful installation the following message will be displayed:
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Install ng-lib for Angular v9
✅️ Added dependency
UPDATE src/app/app.module.ts (466 bytes)
UPDATE src/polyfills.ts (3031 bytes)
UPDATE package.json (1378 bytes)
√ Packages installed successfully.
✅️ Update package.json
✅️ Created scully configuration file in scully.{{yourApp}}.config.js
CREATE scully.{{yourApp}}.config.js (109 bytes)
UPDATE package.json (1438 bytes)Run the following command to generate a blog module.
generate @scullyio/init:blogNow, remove the app.component.html file's content just leave the <router-outlet></router-outlet> tag.
Create a Home Module with routes configured and with a Home Component with the following command:
ng generate module home --route=home --module=app-routingScully depends on the route entry point.
Open the app-routing.module.ts file and set an empty path attribute for the home route as shown below:
const routes: Routes = [
// ...
{
path: '',
loadChildren: () => import('./home/home.module').then(m => m.HomeModule),
},
];Scully provides a service for accessing generated routes with ease.
Open the home.component.ts file and add the following code:
import {ScullyRoutesService} from '@scullyio/ng-lib';
import {Observable} from 'rxjs';
@Component()
//...
export class HomeComponent implements OnInit {
links$: Observable<any> = this.scully.available$;
constructor(private scully: ScullyRoutesService) {}
ngOnInit() {
// debug current pages
this.links$.subscribe(links => {
console.log(links);
});
}
}Now, it is possible to loop through the links inside the template by opening the home.component.html file and adding the following code:
<p>home works!</p>
<ul>
<li *ngFor="let page of links$ | async">{{ page.route }}</li>
</ul>NOTE: If Scully's route service is not added, it does not pre-render pages.
At this point, the Angular project with Scully is ready.
Fist, build the Angular application by running the following command:
ng buildNow, build Scully and turn the Angular app into a pre-rendered static site.
npm run scullyCongratulations! You have turned your Angular application into a wicked fast pre-rendered one thanks to Scully.
The built version of the static site is located in the ./dist/static folder. It contains all the static pages.
NOTE: In case of any errors or warnings during the build process, please follow the instructions in the errors/warnings section or submit an issue.
Serve the content of the static site by running:
npm run scully serveThe above command creates two web servers, one for the Angular app and one for the Scully app.
Extra: While serving the Scully app, disable JavaScript and the site's navigation still works. More importantly, most parts of the site still work even though JS has been disabled.
Extra: In order to debug the Scully application with ngServe, make sure to run:
npm run scullyThen, start the server:
npm run scully:serveScully will use the generated HTML to fill in the ng serve's session content.