Build commands
These commands will allow you to generate the code that can be used to run or analyze a Frontity project

The build process

When you do npx frontity build you generate a build folder with several files.
You'll get something similar to this:
1
β”œβ”€β”€ build
2
β”‚ β”œβ”€β”€ analyze
3
β”‚ β”‚ β”œβ”€β”€ module-development.html
4
β”‚ β”‚ └── server-development.html
5
β”‚ β”œβ”€β”€ bundling
6
β”‚ β”‚ β”œβ”€β”€ chunks.module.json
7
β”‚ β”‚ └── entry-points
8
β”‚ β”‚ β”œβ”€β”€ server.ts
9
β”‚ β”‚ └── my-frontity-project
10
β”‚ β”‚ └── client.ts
11
β”‚ β”œβ”€β”€ server.js
12
β”‚ └── static
13
...
14
β”‚ β”œβ”€β”€ xxxxx1.module.js
15
β”‚ β”œβ”€β”€ xxxxx2.module.js
Copied!
The most important file for deployments in any hosting is server.js, which is actually a middleware that can be inserted in a custom web server.

How to execute a Frontity project in production after the build

npx frontity serve

You can directly execute this server.js by using the command npx frontity serve.
So, easy way of executing a Frontity project in any Node.js server:
    Launch remotely npx frontity build to generate the build folder.
    Launch remotely npx frontity serve to launch a web server that makes use of the server.js generated in the previous step.

Using server.js as a middleware

You can also use this generated server.js as part of a custom server like it's mentioned here.
1
// lambda.js
2
const awsServerlessExpress = require("aws-serverless-express");
3
const app = require("./build/server.js").default;
4
const server = awsServerlessExpress.createServer(app);
5
​
6
exports.handler = (event, context) => {
7
awsServerlessExpress.proxy(server, event, context);
8
};
Copied!

The bundle analyzer

Frontity generates some reports automatically by using Webpack Bundle Analyzer.
When doing npx frontity build you get a build folder in the root of your project.
1
β”œβ”€β”€ build
2
β”‚ β”œβ”€β”€ analyze
3
β”‚ β”‚ β”œβ”€β”€ module-development.html
4
β”‚ β”‚ └── server-development.html
5
β”‚ β”œβ”€β”€ bundling
6
β”‚ β”‚ β”œβ”€β”€ chunks.module.json
7
β”‚ β”‚ └── entry-points
8
β”‚ β”‚ β”œβ”€β”€ my-frontity-project
9
β”‚ β”‚ β”‚ └── client.ts
10
β”‚ β”‚ └── server.ts
11
β”‚ β”œβ”€β”€ server.js
12
β”‚ └── static
13
β”‚ β”œβ”€β”€ my-frontity-project.module.js
14
β”‚ └── list.module.js
Copied!
Inside that build folder there is a .html file generated at analyze/module-development.html. This file is a visual report in the form of a tree generated by Webpack Bundle Analyzer.
This report shows you the modules included on each bundle and the size of each one, so that you can analyze them and maybe decide using other modules (or not including a specific module at all) to reduce the size of the final bundle.
Last modified 4mo ago