Stormkit LogoStormkit Logo WhiteStormkit

Deploying Angular websites

It's easy to deploy angular websites with Stormkit. Simply create your angular application by connecting the repository with your favorite provider and head to the environment configuration page.

SPA mode

If you want to deploy single page applications, you don't need to do much. Leave the serverless toggle off, specify the build command and your environment variables and hit deploy. Below is an example of the build configuration for single page applications.SPA config

Important: Stormkit expects to have an index.html file at the top level of the published folder. Usually, you don't need to anything for this as it is the default behaviour.

Finally, make sure to create a stormkit.config.yml file at the root level of the repository. We need to tell Stormkit to redirect all requests to theindex.html file:app: - redirects: - from: /* to: /index.html assets: false

Universal mode

If are using an Angular Universal application, enable the serverless toggle, specify the build command and your environment variables. Below is an example of the build configuration for universal applications.SSR config

Next, since Stormkit runs on a serverless environment, we will need to change the server.ts file and export the express app instead of listening to a port.// server.ts // You may still want to keep this around for local development // The SK_APP_ID is injected on build time by Stormkit. This way you // can distinguish between Stormkit and local environments. if (!process.env.SK_APP_ID) { app.listen(PORT, () => { console.log(`Node server listening on http://localhost:${PORT}`); }); } export default app; // app is the return value of the express() call.

We will also need to update the webpack.server.config.js file and tell webpack to use commonjs style exports:// webpack.server.config.js output: { // ... libraryTarget: "commonjs" }

Important: Stormkit expects to have a server.js file at the top level of the published folder. Usually, you don't need to anything for this as it is the default behaviour.

Finally, make sure to create a stormkit.config.yml file at the root level of the repository. We need to tell Stormkit to redirect all static assets to the CDN:app: - redirects: - ext: js,css,ico,png,jpg cdn: true